Changeset 1642
- Timestamp:
- 03/19/07 02:24:19
- Files:
-
- trunk/cherrypy/restsrv/__init__.py (modified) (1 diff)
- trunk/cherrypy/restsrv/restctl (modified) (5 diffs)
- trunk/cherrypy/restsrv/restd.py (modified) (2 diffs)
- trunk/cherrypy/restsrv/win32.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/restsrv/__init__.py
r1639 r1642 45 45 from cherrypy.restsrv import win32 46 46 engine = win32.Engine() 47 del win32 47 48 except ImportError: 48 49 from cherrypy.restsrv import base 49 50 engine = base.Engine() 51 del base trunk/cherrypy/restsrv/restctl
r1639 r1642 2 2 3 3 import getopt 4 import os 5 localDir = os.path.dirname(__file__) 4 6 import signal 5 7 import sys … … 28 30 print """ 29 31 Usage: 30 webctl [options] command32 restctl [options] command 31 33 32 34 … … 61 63 62 64 def spawn_child(opts): 63 args = [] 64 for k, v in opts: 65 restd_path = os.path.join(localDir, 'restd.py') 66 args = [sys.executable, restd_path] 67 for k, v in opts.iteritems(): 65 68 if v: 66 69 args.append('%s=%s' % (k, v)) … … 68 71 args.append(k) 69 72 70 pid = os.spawn pv(os.P_NOWAIT, 'restd', ' '.join(args))73 pid = os.spawnv(os.P_NOWAIT, sys.executable, args) 71 74 72 75 … … 85 88 86 89 if __name__ == '__main__': 87 try: 88 run() 89 except: 90 help() 91 sys.exit(2) 90 run() trunk/cherrypy/restsrv/restd.py
r1639 r1642 41 41 42 42 43 def importer(name) 43 def importer(name): 44 44 # Wrap the given 'name' in a closure. 45 45 def _import(): … … 52 52 if '--project' in opts: 53 53 # delay import until after daemonize has a chance to run 54 engine.subscribe('start', importer(opts['--project']))54 restsrv.engine.subscribe('start', importer(opts['--project'])) 55 55 56 56 if 'win' not in sys.platform: 57 engine.subscribe('start', restsrv.plugins.daemonize)57 restsrv.engine.subscribe('start', restsrv.plugins.daemonize) 58 58 59 engine.start()60 engine.block()59 restsrv.engine.start() 60 restsrv.engine.block() 61 61 62 62 trunk/cherrypy/restsrv/win32.py
r1639 r1642 1 1 """Windows service for restsrv. Requires pywin32.""" 2 2 3 import thread 4 import win32api 5 import win32con 6 import win32event 7 import win32service 3 8 import win32serviceutil 4 import win32service5 import win32event6 import win32con7 import win32api8 9 9 10 from cherrypy.restsrv import base … … 29 30 """Block forever (wait for stop(), KeyboardInterrupt or SystemExit).""" 30 31 try: 31 win32event.WaitForSingleObject(self.stop_event, 32 win32event.INFINITE) 32 win32event.WaitForSingleObject(self.stop_event, win32event.INFINITE) 33 33 except SystemExit: 34 34 self.log('SystemExit raised: shutting down engine')

