Detect already running web2py

2 views
Skip to first unread message

Iceberg

unread,
Mar 22, 2009, 9:50:01 PM3/22/09
to web2py Web Framework
Hi Massimo,

At least in Windows platform, when one "web2py -i 0.0.0.0 -p 8000"
process in running, I noticed that local administrator can still start
another "web2py -i 0.0.0.0 -p 8000" process without any error message,
but of course the second web2py process can not accept any request. So
I suggest to add some detect code at the beginning of web2py
launching. Something like this:

def __main__():
# parse commandline and get the bindIP and bindPort, then
detectAddr = '127.0.0.1' if bindIP=='0.0.0.0' else bindIP
try: urllib.urlopen('http://%s:%s'% (detectAddr, bindPort)).read()
except IOError: pass # the bindAddr and bindPort is vacant
else: sys.exit('%s:%s is occupied'%(detectAddr,bindPort))
...... # Go on to start web2py main process

This code can let novice make fewer mistakes.


Regards,
Iceberg

mdipierro

unread,
Mar 22, 2009, 11:04:04 PM3/22/09
to web2py Web Framework
I like the idea and I will add it asap. Thanks.

Massimo
Reply all
Reply to author
Forward
0 new messages