Right ......
start by downloading NSSM from http://nssm.cc/ .
Inside the archive, select the folder corresponding to your Windows installation: win32 or win64.
Then, extract the relevant binary to a path of your choice, let's say c:\nssm\ .
Alright, almost there....
Open a dos prompt, cd into c:\nssm\ and issue
nssm install
A basic GUI pops up....
Choose a service name (I chose "web2py_web"), then:
- if you have the binary version, click on Browse and find web2py.exe
- if you have the source version, click on Browse and find python.exe
In my case, source version it is, so I went for python.exe inside c:\python27\
In the options tab, if you have the binary version, use -a hello to pass, e.g., the parameter for the password
If you have the source version, use "c:\fullpath to\web2py.py" -a hello quotes included.
I chose the most hidious place for it, the Desktop on an XP installation .....
This is what is looks like
You can't see it, but trust me, it's
"C:\Documents and Settings\Administrator\Desktop\web2py_source\webp2y.py" -a hello
be sure to have them all filled (included service name) and click on the "Install service" tab.
Now, if you open the service management interface, you'll see you service ready to be started.
This is what it happens as seen on procexp (cool task manager replacement)
So, nssm is the "master" process "watching over" the python executable running web2py.py ....
To use the scheduler, procedure is exactly the same, except you must use instead of
-a hello
the arguments
-K appname
NB: if you need multiple workers, install a separate service for each one. This is done because when you use, e.g.
-K appname,appname
to start two schedulers in the same shell, what happens is that a "master" web2py.py process spawns 2 separate processes for the workers. Under nssm, they'd become
-- nssm.exe `-- python.exe web2py.py `-- python.exe running scheduler 1 `-- python.exe running scheduler 2
as it is, nssm can only "watch" over its "direct" children, that is python.exe web2py.py: the issue is that python.exe web2py.py will be "alive" until BOTH workers die, that is not what you want.....
You want each of the schedulers to be restarted as soon as they die.
If you use instead two separate instances (same configuration, -a appname for both, 2 different service names) what will happen is
-- nssm.exe `-- python.exe running scheduler 1 -- nssm.exe `-- python.exe running scheduler 2
so each instance of nssm will watch over its children and restart the scheduler as soon as it dies.
That's all, folks!
Comments (1)
0
icreator 9 years ago
I install web2py.exe with nssm - good
But what must I do for Apache 2 ?
How config that?