Pyramid为autorestart监视的其他文件/目录

时间:2015-04-24 14:30:51

标签: python pyramid

如果应用范围中的某些.py.ini文件发生了变化,Pyramid会自动重启。

我需要观看更多文件(它们不是.py.ini) - 如何将它们添加到金字塔监控中?

1 个答案:

答案 0 :(得分:1)

在自定义watchdog实现中实现所需行为时,您(并且可能是某天金字塔本身)可能会更好。按照我的想法......

创建一个脚本,使您的PasteDeploy .ini文件运行pserve命令,并为要监视的文件扩展名安装监视程序。

Watchdog事件处理程序只会更改.ini文件的修改时间,因为此文件已由金字塔观察程序监视。

$ touch pyramid.ini

导致重新加载:

pyramid.ini changed; reloading...
-------------------- Restarting --------------------
2015-04-29 08:51:05,216 INFO  [ZEO.ClientStorage] ('localhost', 8100) ClientStorage (pid=5263) created RW/normal for storage: '1'
2015-04-29 08:51:05,217 INFO  [ZEO.cache] created temporary cache file '<fdopen>'
2015-04-29 08:51:05,227 INFO  [ZEO.ClientStorage] ('localhost', 8100) Testing connection <ManagedClientConnection ('127.0.0.1', 8100)>
2015-04-29 08:51:05,228 INFO  [ZEO.zrpc.Connection('C')] (127.0.0.1:8100) received handshake 'Z3101'
2015-04-29 08:51:05,329 INFO  [ZEO.ClientStorage] ('localhost', 8100) Server authentication protocol None
2015-04-29 08:51:05,331 INFO  [ZEO.ClientStorage] ('localhost', 8100) Connected to storage: ('localhost', 8100)
2015-04-29 08:51:05,332 INFO  [ZEO.ClientStorage] ('localhost', 8100) No verification necessary -- empty cache
Starting server in PID 5263.
serving on http://0.0.0.0:6543

您甚至可以从pserve模块中导入适合您用例的有用内容。看看这个scripting approach,了解如何驾驶看门狗。