如何configurationPython脚本作为守护程序运行

我有一对坐在loadbalancer后面的web服务器,我在这里find了“watcher.py”: https : //github.com/splitbrain/Watcher

我select这个脚本有几个原因:通过文件夹recursion,大量的触发选项

无论如何,我将使用它来在负载均衡的服务器之间同步网页内容。 有没有办法确保这个脚本将在启动时运行?

我发现处理这样的应用程序最简单的方法是安装supervisord ,然后使用它来启动,监视和收集脚本的输出。

这里是一个示例supervisorconfiguration文件:

 [program:watcher] command = /usr/bin/python /path/to/watcher.py stdout_logfile = /var/log/watcher-stdout.log stdout_logfile_maxbytes = 10MB stdout_logfile_backups = 5 stderr_logfile = /var/log/watcher-stderr.log stderr_logfile_maxbytes = 10MB stderr_logfile_backups = 5