Running the scheduler as a windows service using nssm

425 views
Skip to first unread message

Tim Richardson

unread,
Dec 16, 2012, 8:05:16 AM12/16/12
to web...@googlegroups.com
I used nssm to create a service which runs a scheduler instance. I'm using AcitveState python 2.7 on a windows 2003 server.
I told nssm to run
pythonw.exe d:\web2py2x\web2py.py -K app1,app2

The service runs so I guess all is well, and I've made it automatic whch I hope means it comes back after a reboot.

I know little about services so I hope this is ok.

regards

Tim


Niphlod

unread,
Dec 16, 2012, 9:33:32 AM12/16/12
to web...@googlegroups.com

checking on services is easy: reboot your machine and see if it the process is restarted. On the new task manager (WS2008 and on) you can have a column showing the command line that the process is running. On XP, WS2003, etc that doesn't have natively this functionality, you can use procexp.exe.

I'd run 2 separate services for each app, and here's the reason.
When you start web2py.py -K app1, app2 what is really going on is


In that case, nssm will check on the availability of the master web2py.py process (pid 4064 in the image): if scheduler of app1 dies for whatever reason(pid 1184), web2py.py will not restart it.
nssm will restart the web2py.py process when both app1 and app2 die (in that case, the master process dies because there are no child processes attached, and nssm will detect the death and restart it).

However, when you run web2py.py -K app1,

web2py.py will not spawn a master process with a child: it will run on the master process the scheduler of app1, so nssm will restart it as soon as it dies.

Tim Richardson

unread,
Dec 16, 2012, 7:34:08 PM12/16/12
to web...@googlegroups.com
Thanks for the tips. I've implemented two schedulers. Now I understand the difference between starting the scheduler with 1 app vs > 1 apps.

nssm is very easy to use.

I think for Windows deployment, running the scheduler as a service would be a very common use-case. Perhaps worthy of a paragraph in the book. 

Massimo Di Pierro

unread,
Dec 16, 2012, 10:08:29 PM12/16/12
to web...@googlegroups.com
Agreed. Can you help us write it?

Tim Richardson

unread,
Dec 17, 2012, 11:28:01 PM12/17/12
to web...@googlegroups.com


On Monday, December 17, 2012 2:08:29 PM UTC+11, Massimo Di Pierro wrote:
Agreed. Can you help us write it?

I just tried my first "pull request" so you should see that in the web2py-book repository on github. I hope.
Reply all
Reply to author
Forward
0 new messages