def main(): global opts parser = get_parser() opts, args = parser.parse_args() load_config_or_exit(opts.configfile) signal.signal(signal.SIGINT, sigterm_handler) signal.signal(signal.SIGTERM, sigterm_handler) if opts.foreground: log_to_stream(sys.stderr, level=logging.DEBUG) else: log_to_syslog('beakerd') pid_file = opts.pid_file if pid_file is None: pid_file = config.get("PID_FILE", "/var/run/beaker/beakerd.pid") d = daemon.DaemonContext(pidfile=pidfile.TimeoutPIDLockFile(pid_file, acquire_timeout=0), detach_process=True) try: d.open() except pidlockfile.AlreadyLocked: log.fatal("could not acquire lock on %s, exiting" % pid_file) sys.stderr.write("could not acquire lock on %s" % pid_file) sys.exit(1) schedule()
def main(): parser = get_parser() opts, args = parser.parse_args() load_config_or_exit(opts.configfile) if opts.check and opts.background: parser.error( '--check --background makes no sense, how will you know the result?' ) if not opts.background: log_to_stream(sys.stderr, level=logging.DEBUG if opts.debug else logging.WARNING) return doit(opts) else: pidlockfile = PIDLockFile(PIDFILE) existing_pid = pidlockfile.read_pid() if existing_pid: if process_is_alive(existing_pid): sys.stderr.write( 'Another beaker-init process is running (pid %s)\n' % existing_pid) return 1 else: sys.stderr.write('Pid file %s exists but pid %s is dead, ' 'removing the pid file\n' % (PIDFILE, existing_pid)) pidlockfile.break_lock() with daemon.DaemonContext(pidfile=pidlockfile, detach_process=True): log_to_syslog('beaker-init') return doit(opts)
def main(): parser = get_parser() opts, args = parser.parse_args() load_config_or_exit(opts.configfile) if opts.check and opts.background: parser.error('--check --background makes no sense, how will you know the result?') if not opts.background: log_to_stream(sys.stderr, level=logging.DEBUG if opts.debug else logging.WARNING) return doit(opts) else: pidlockfile = PIDLockFile(PIDFILE) existing_pid = pidlockfile.read_pid() if existing_pid: if process_is_alive(existing_pid): sys.stderr.write('Another beaker-init process is running (pid %s)\n' % existing_pid) return 1 else: sys.stderr.write('Pid file %s exists but pid %s is dead, ' 'removing the pid file\n' % (PIDFILE, existing_pid)) pidlockfile.break_lock() with daemon.DaemonContext(pidfile=pidlockfile, detach_process=True): log_to_syslog('beaker-init') return doit(opts)
"WATCHDOG_PID_FILE", "/var/run/beaker-lab-controller/beaker-watchdog.pid") # HubProxy will try to log some stuff, even though we # haven't configured our logging handlers yet. So we send logs to stderr # temporarily here, and configure it again below. log_to_stream(sys.stderr, level=logging.WARNING) try: watchdog = Watchdog(conf=conf) except Exception, ex: sys.stderr.write("Error starting beaker-watchdog: %s\n" % ex) sys.exit(1) if opts.foreground: log_to_stream(sys.stderr, level=logging.DEBUG) main_loop(watchdog, conf) else: # See BZ#977269 watchdog.close() with daemon.DaemonContext(pidfile=pidfile.TimeoutPIDLockFile( pid_file, acquire_timeout=0), detach_process=True): log_to_syslog('beaker-watchdog') main_loop(watchdog, conf) print 'exiting program' if __name__ == '__main__': main()
if not conf.get('ARCHIVE_SERVER'): sys.stderr.write( 'Archive server settings are missing from config file\n') sys.exit(1) # HubProxy will try to log some stuff, even though we # haven't configured our logging handlers yet. So we send logs to stderr # temporarily here, and configure it again below. log_to_stream(sys.stderr, level=logging.WARNING) try: logarchiver = LogArchiver(conf=conf) except Exception, ex: sys.stderr.write("Error starting beaker-transfer: %s\n" % ex) sys.exit(1) if opts.foreground: log_to_stream(sys.stderr, level=logging.DEBUG) main_loop(logarchiver=logarchiver, conf=conf) else: # See BZ#977269 logarchiver.close() with daemon.DaemonContext(pidfile=pidfile.TimeoutPIDLockFile( pid_file, acquire_timeout=0), detach_process=True): log_to_syslog('beaker-transfer') main_loop(logarchiver=logarchiver, conf=conf) if __name__ == '__main__': main()
if pid_file is None: pid_file = conf.get("PROVISION_PID_FILE", "/var/run/beaker-lab-controller/beaker-provision.pid") # HubProxy will try to log some stuff, even though we # haven't configured our logging handlers yet. So we send logs to stderr # temporarily here, and configure it again below. log_to_stream(sys.stderr, level=logging.WARNING) try: poller = CommandQueuePoller(conf=conf) except Exception, ex: sys.stderr.write('Error starting beaker-provision: %s\n' % ex) sys.exit(1) if opts.foreground: log_to_stream(sys.stderr, level=logging.DEBUG) main_loop(poller=poller, conf=conf) else: # See BZ#977269 poller.close() with daemon.DaemonContext(pidfile=pidfile.TimeoutPIDLockFile( pid_file, acquire_timeout=0),detach_process=True): log_to_syslog('beaker-provision') try: main_loop(poller=poller, conf=conf) except Exception: logger.exception('Unhandled exception in main_loop') raise if __name__ == '__main__': main()
pid_file = opts.pid_file if pid_file is None: pid_file = conf.get("PROXY_PID_FILE", "/var/run/beaker-lab-controller/beaker-proxy.pid") # HubProxy will try to log some stuff, even though we # haven't configured our logging handlers yet. So we send logs to stderr # temporarily here, and configure it again below. log_to_stream(sys.stderr, level=logging.WARNING) try: proxy = Proxy(conf=conf) except Exception, ex: sys.stderr.write("Error starting beaker-proxy: %s\n" % ex) sys.exit(1) if opts.foreground: log_to_stream(sys.stderr, level=logging.DEBUG) main_loop(proxy=proxy, conf=conf) else: # See BZ#977269 proxy.close() with daemon.DaemonContext(pidfile=pidfile.TimeoutPIDLockFile( pid_file, acquire_timeout=0), detach_process=True): log_to_syslog('beaker-proxy') main_loop(proxy=proxy, conf=conf) if __name__ == '__main__': main()
conf = get_conf() logging.getLogger().setLevel(logging.DEBUG) pid_file = opts.pid_file if pid_file is None: pid_file = conf.get("PROXY_PID_FILE", "/var/run/beaker-lab-controller/beaker-proxy.pid") # HubProxy will try to log some stuff, even though we # haven't configured our logging handlers yet. So we send logs to stderr # temporarily here, and configure it again below. log_to_stream(sys.stderr, level=logging.WARNING) try: proxy = Proxy(conf=conf) except Exception, ex: sys.stderr.write("Error initializing Proxy: %s\n" % ex) sys.exit(1) if opts.foreground: log_to_stream(sys.stderr, level=logging.DEBUG) main_loop(proxy=proxy, conf=conf) else: # See BZ#977269 proxy.close() with daemon.DaemonContext(pidfile=pidfile.TimeoutPIDLockFile( pid_file, acquire_timeout=0), detach_process=True): log_to_syslog('beaker-proxy') main_loop(proxy=proxy, conf=conf) if __name__ == '__main__': main()
conf = get_conf() pid_file = opts.pid_file if pid_file is None: pid_file = conf.get("WATCHDOG_PID_FILE", "/var/run/beaker-lab-controller/beaker-watchdog.pid") # HubProxy will try to log some stuff, even though we # haven't configured our logging handlers yet. So we send logs to stderr # temporarily here, and configure it again below. log_to_stream(sys.stderr, level=logging.WARNING) try: watchdog = Watchdog(conf=conf) except Exception, ex: sys.stderr.write("Error initializing Watchdog: %s\n" % ex) sys.exit(1) if opts.foreground: log_to_stream(sys.stderr, level=logging.DEBUG) main_loop(watchdog, conf) else: # See BZ#977269 watchdog.close() with daemon.DaemonContext(pidfile=pidfile.TimeoutPIDLockFile( pid_file, acquire_timeout=0), detach_process=True): log_to_syslog('beaker-watchdog') main_loop(watchdog, conf) print 'exiting program' if __name__ == '__main__': main()
if pid_file is None: pid_file = conf.get("PROVISION_PID_FILE", "/var/run/beaker-lab-controller/beaker-provision.pid") # HubProxy will try to log some stuff, even though we # haven't configured our logging handlers yet. So we send logs to stderr # temporarily here, and configure it again below. log_to_stream(sys.stderr, level=logging.WARNING) try: poller = CommandQueuePoller(conf=conf) except Exception, ex: sys.stderr.write('Error initializing CommandQueuePoller: %s\n' % ex) sys.exit(1) if opts.foreground: log_to_stream(sys.stderr, level=logging.DEBUG) main_loop(poller=poller, conf=conf) else: # See BZ#977269 poller.close() with daemon.DaemonContext(pidfile=pidfile.TimeoutPIDLockFile( pid_file, acquire_timeout=0),detach_process=True): log_to_syslog('beaker-provision') try: main_loop(poller=poller, conf=conf) except Exception: logger.exception('Unhandled exception in main_loop') raise if __name__ == '__main__': main()
pid_file = opts.pid_file if pid_file is None: pid_file = conf.get("WPID_FILE", "/var/run/beaker-lab-controller/beaker-transfer.pid") if not conf.get('ARCHIVE_SERVER'): sys.stderr.write('Archive server settings are missing from config file\n') sys.exit(1) # HubProxy will try to log some stuff, even though we # haven't configured our logging handlers yet. So we send logs to stderr # temporarily here, and configure it again below. log_to_stream(sys.stderr, level=logging.WARNING) try: logarchiver = LogArchiver(conf=conf) except Exception, ex: sys.stderr.write("Error starting beaker-transfer: %s\n" % ex) sys.exit(1) if opts.foreground: log_to_stream(sys.stderr, level=logging.DEBUG) main_loop(logarchiver=logarchiver, conf=conf) else: # See BZ#977269 logarchiver.close() with daemon.DaemonContext(pidfile=pidfile.TimeoutPIDLockFile( pid_file, acquire_timeout=0), detach_process=True): log_to_syslog('beaker-transfer') main_loop(logarchiver=logarchiver, conf=conf) if __name__ == '__main__': main()