Changeset 311
- Timestamp:
- 06/25/08 00:34:56 (2 months ago)
- Location:
- branches/0.5/daemon/orbited
- Files:
-
- 4 modified
-
config.py (modified) (3 diffs)
-
control.py (modified) (5 diffs)
-
logger/test.py (modified) (2 diffs)
-
start.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.5/daemon/orbited/config.py
r294 r311 4 4 map = { 5 5 '[global]': { 6 'dispatch.enabled': '0' 6 'dispatch.enabled': '0', 7 'pid.location': '/tmp/orbited.pid' 7 8 }, 8 9 '[logging]': { … … 27 28 '[global]': { 28 29 'dispatch.enabled': '1', 29 'dispatch.port': '9000' 30 'dispatch.port': '9000', 30 31 }, 31 32 '[access]': [ … … 73 74 pass 74 75 print "Could not locate configuration file. Using default configuration" 76 for key, val in defaults.items(): 77 if isinstance(map.get(key), dict): 78 map[key].update(val) 79 else: 80 map[key] = val 75 81 map.update(defaults) 76 82 -
branches/0.5/daemon/orbited/control.py
r291 r311 6 6 from start import logger 7 7 from start import main as orbited_main 8 from config import map as config 9 10 pid_location = config['[global]']['pid.location'] 8 11 9 12 def start(): 10 13 print "Starting Orbited Daemon" 11 checkpidfile = open('/tmp/orbited.pid', 'a') 14 15 checkpidfile = open(pid_location, 'a') 12 16 try: 13 17 fcntl.lockf(checkpidfile , fcntl.LOCK_EX|fcntl.LOCK_NB) … … 53 57 # Try to get an exclusive lock on the file. This will fail 54 58 # if another process has the file locked. 55 pidfile = open( '/tmp/orbited.pid', 'w')59 pidfile = open(pid_location, 'w') 56 60 logger.debug('d3') 57 61 fcntl.lockf(pidfile, fcntl.LOCK_EX|fcntl.LOCK_NB) … … 67 71 def stop(): 68 72 print "Stopping Orbited Daemon" 69 wpidfile = open('/tmp/orbited.pid', 'a')73 checkpidfile = open(pid_location, 'a') 70 74 try: 71 fcntl.lockf( wpidfile, fcntl.LOCK_EX|fcntl.LOCK_NB)72 fcntl.lockf( wpidfile, fcntl.LOCK_UN)75 fcntl.lockf(checkpidfile, fcntl.LOCK_EX|fcntl.LOCK_NB) 76 fcntl.lockf(checkpidfile, fcntl.LOCK_UN) 73 77 except IOError: 74 78 pass … … 77 81 raise SystemExit 78 82 79 rpidfile = open( '/tmp/orbited.pid', 'r')83 rpidfile = open(pid_location, 'r') 80 84 try: 81 85 pid = int(rpidfile.read()) 82 86 except ValueError: 83 print "Invalid pid file: /tmp/orbited.pid"87 print "Invalid pid file: %s" % (pid_location,) 84 88 raise SystemExit 85 89 … … 95 99 96 100 def status(): 97 wpidfile = open( '/tmp/orbited.pid', 'a')101 wpidfile = open(pid_location, 'a') 98 102 try: 99 103 fcntl.lockf(wpidfile, fcntl.LOCK_EX|fcntl.LOCK_NB) -
branches/0.5/daemon/orbited/logger/test.py
r289 r311 1 if True:1 if False: 2 2 import log 3 3 config = { … … 11 11 }, 12 12 '[loggers]': { 13 ' access': 1,13 'ACCESS': 1, 14 14 'HTTPDaemon': '2', 15 15 } -
branches/0.5/daemon/orbited/start.py
r302 r311 8 8 #from revolved import RevolvedConnection 9 9 logger = get_logger('Daemon') 10 #if 'INDEX' in config['[static]']: 11 # print 'index found', config['[static]']['INDEX'] 12 # root = static.File(config['[static]']['INDEX']) 13 #else: 10 14 root = resource.Resource() 11 15 static_files = static.File(os.path.join(os.path.split(__file__)[0], 'static')) … … 13 17 site = server.Site(root) 14 18 19 def setup_static(taken): 20 for key, val in config['[static]'].items(): 21 if key in taken: 22 logger.error("cannot mount static directory with reserved name %s" % key) 23 sys.exit(0) 24 if key == 'INDEX': 25 key = '' 26 root.putChild(key, static.File(val)) 15 27 16 28 def main(): … … 26 38 if config['[global]']['dispatch.enabled'] == '1': 27 39 root.putChild('legacy', DispatchFactory()) 28 40 setup_static(['echo', 'proxy', 'binaryproxy', 'websocket']) 29 41 for addr in config['[listen]']: 30 42 url = urlparse.urlparse(addr)