2

According to the following I need to create the following file:

/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

The Question

What do I do if I want to have a scheduler for 2 apps?

Should I create two .conf files or create 1 file with 2 instances of the exec command?

The solution with two files would be:

/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

The solution with one file:

/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

sorry if this is obvious but I have no experience in writing conf files and how this part of the system works.

thank you

evan54
  • 3,585
  • 5
  • 34
  • 61

1 Answers1

0

ok I think both are possible, I settled on using a two file solution.

The complete files are as follows (note I've substituted <user> with www-data which is the actual user):

/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

The solution with one file:

/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

In the one file App1,App2 should NOT have a space in between.

evan54
  • 3,585
  • 5
  • 34
  • 61