def main(): """ Running this file gets first parameter to the type of "runner" and the location of the app module relative to the location where handler.py activated. The format of the argument is: {runner-type}:{module-name}.{class-name}. you can not connect to the remote logger. runner-type can be one of the keys that exist in the dictionary APP_RUNNERS. """ command, args = sys.argv[1], sys.argv[2:] for arg in args: if arg.startswith('--'): if '=' in arg: key, value = arg.split('=', 1) else: key, value = arg, True try: setter = ARG_SETTERS[key] except KeyError: raise KeyError('There is no support for this argument (%s).' % (key, )) setter(value) init_logging() app_runner_type, app_namespace = command.split(':', 1) APP_RUNNERS[app_runner_type](app_namespace).run()
def main(): config.STD_LOGGING = True init_logging() watchdog = WatchdogChain(patterns=config.RELOAD_PATTERNS) watchdog.add(OneModuleWatchdog("webx")) watchdog.add(OneDirWatchdog(realpath(curdir))) args = [sys.executable] + sys.argv[1:] log_debug >> "STARTING RELOADER.." try: while True: log_debug >> "RUNNING PROCESS.." process = subprocess.Popen(args) try: for event in watchdog.wait_for_events(): log_debug >> repr(event) finally: log_debug >> "KILLING PROCESS NOW.." process.kill() process.wait() log_debug >> "RELOADING NOW.." except KeyboardInterrupt: pass