如何为多个应用程序部署 web2py 调度程序?

How do I deploy the web2py scheduler for multiple apps?

根据下面我需要创建如下文件:

/etc/init/web2py-scheduler.conf

http://web2py.com/books/default/chapter/29/13/deployment-recipes#Start-the-scheduler-as-a-Linux-service--upstart-

web2py-scheduler.conf

description "web2py task scheduler"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn limit 8 60 # Give up if restart occurs 8 times in 60 seconds.
exec sudo -u <user> python /home/<user>/web2py/web2py.py -K <myapp>
respawn

问题

如果我想为 2 个应用程序设置一个调度程序,我该怎么办?

我应该创建两个 .conf 文件还是创建一个包含 2 个 exec command 实例的文件?

有两个文件的解决方案是:

/etc/init/web2py-scheduler.app1.conf:

description "web2py task scheduler App1"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn limit 8 60 # Give up if restart occurs 8 times in 60 seconds.
exec sudo -u <user> python /home/<user>/web2py/web2py.py -K App1
respawn

/etc/init/web2py-scheduler.app2.conf:

description "web2py task scheduler App2"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn limit 8 60 # Give up if restart occurs 8 times in 60 seconds.
exec sudo -u <user> python /home/<user>/web2py/web2py.py -K App2
respawn

一个文件的解决方案:

/etc/init/web2py-scheduler.conf:

description "web2py task scheduler"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn limit 8 60 # Give up if restart occurs 8 times in 60 seconds.
exec sudo -u <user> python /home/<user>/web2py/web2py.py -K App1
exec sudo -u <user> python /home/<user>/web2py/web2py.py -K App2
respawn

抱歉,如果这很明显,但我没有编写 conf 文件以及系统的这一部分如何工作的经验。

谢谢

好的,我认为两者都是可能的,我决定使用双文件解决方案。

完整文件如下(注意我把<user>换成了www-data,也就是实际用户):

/etc/init/web2py-scheduler.app1.conf:

description "web2py task scheduler App1"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn limit 8 60 # Give up if restart occurs 8 times in 60 seconds.
exec sudo -u www-data python /home/www-data/web2py/web2py.py -K App1
respawn

/etc/init/web2py-scheduler.app2.conf:

description "web2py task scheduler App2"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn limit 8 60 # Give up if restart occurs 8 times in 60 seconds.
exec sudo -u www-data python /home/www-data/web2py/web2py.py -K App2
respawn

一个文件的解决方案:

/etc/init/web2py-scheduler.conf:

description "web2py task scheduler"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn limit 8 60 # Give up if restart occurs 8 times in 60 seconds.
exec sudo -u www-data python /home/www-data/web2py/web2py.py -K App1,App2
respawn

在一个文件 App1,App2 之间不应有 space。