def main(): signal.signal(signal.SIGTERM, handle_signal) signal.signal(signal.SIGINT, handle_signal) Path(settings.pcsd_log_location).touch(mode=0o600, exist_ok=True) log.setup(settings.pcsd_log_location) env = prepare_env(os.environ, log.pcsd) if env.has_errors: raise SystemExit(1) if env.PCSD_DEBUG: log.enable_debug() sync_config_lock = Lock() ruby_pcsd_wrapper = ruby_pcsd.Wrapper( settings.pcsd_ruby_socket, debug=env.PCSD_DEBUG, ) make_app = configure_app( session.Storage(env.PCSD_SESSION_LIFETIME), ruby_pcsd_wrapper, sync_config_lock, env.PCSD_STATIC_FILES_DIR, disable_gui=env.PCSD_DISABLE_GUI, debug=env.PCSD_DEV, ) pcsd_ssl = ssl.PcsdSSL( server_name=socket.gethostname(), cert_location=settings.pcsd_cert_location, key_location=settings.pcsd_key_location, ssl_options=env.PCSD_SSL_OPTIONS, ssl_ciphers=env.PCSD_SSL_CIPHERS, ) try: SignalInfo.server_manage = HttpsServerManage( make_app, port=env.PCSD_PORT, bind_addresses=env.PCSD_BIND_ADDR, ssl=pcsd_ssl, ).start() except socket.gaierror as e: log.pcsd.error("Unable to bind to specific address(es), exiting: %s ", e) raise SystemExit(1) except OSError as e: log.pcsd.error("Unable to start pcsd daemon, exiting: %s ", e) raise SystemExit(1) except ssl.SSLCertKeyException as e: for error in e.args: log.pcsd.error(error) log.pcsd.error("Invalid SSL certificate and/or key, exiting") raise SystemExit(1) ioloop = IOLoop.current() ioloop.add_callback(sign_ioloop_started) if is_systemd() and env.NOTIFY_SOCKET: ioloop.add_callback(systemd.notify, env.NOTIFY_SOCKET) ioloop.add_callback(config_sync(sync_config_lock, ruby_pcsd_wrapper)) ioloop.start()
def main(): signal.signal(signal.SIGTERM, handle_signal) signal.signal(signal.SIGINT, handle_signal) Path(settings.pcsd_log_location).touch(mode=0o600, exist_ok=True) log.setup(settings.pcsd_log_location) env = prepare_env(os.environ, log.pcsd) if env.has_errors: raise SystemExit(1) if env.PCSD_DEBUG: log.enable_debug() sync_config_lock = Lock() ruby_pcsd_wrapper = ruby_pcsd.Wrapper( pcsd_cmdline_entry=env.PCSD_CMDLINE_ENTRY, gem_home=env.GEM_HOME, debug=env.PCSD_DEBUG, ruby_executable=settings.ruby_executable, https_proxy=env.HTTPS_PROXY, no_proxy=env.NO_PROXY, ) make_app = configure_app( session.Storage(env.PCSD_SESSION_LIFETIME), ruby_pcsd_wrapper, sync_config_lock, env.PCSD_STATIC_FILES_DIR, disable_gui=env.PCSD_DISABLE_GUI, debug=env.PCSD_DEV, ) pcsd_ssl = ssl.PcsdSSL( server_name=socket.gethostname(), cert_location=settings.pcsd_cert_location, key_location=settings.pcsd_key_location, ssl_options=env.PCSD_SSL_OPTIONS, ssl_ciphers=env.PCSD_SSL_CIPHERS, ) try: SignalInfo.server_manage = HttpsServerManage( make_app, port=env.PCSD_PORT, bind_addresses=env.PCSD_BIND_ADDR, ssl=pcsd_ssl, ).start() except socket.gaierror as e: log.pcsd.error( "Unable to bind to specific address(es), exiting: %s ", e ) raise SystemExit(1) except OSError as e: log.pcsd.error("Unable to start pcsd daemon, exiting: %s ", e) raise SystemExit(1) except ssl.SSLCertKeyException as e: for error in e.args: log.pcsd.error(error) log.pcsd.error("Invalid SSL certificate and/or key, exiting") raise SystemExit(1) ioloop = IOLoop.current() ioloop.add_callback(sign_ioloop_started) if is_systemd() and env.NOTIFY_SOCKET: ioloop.add_callback(systemd.notify, env.NOTIFY_SOCKET) ioloop.add_callback(config_sync(sync_config_lock, ruby_pcsd_wrapper)) ioloop.start()