def Main(): args = ParseArguments() SetupLogging(args.log) options = SetupOptions(args.options_file) YcmCoreSanityCheck() extra_conf_store.CallGlobalExtraConfYcmCorePreloadIfExists() code = CompatibleWithCurrentCore() if code: sys.exit(code) # These can't be top-level imports because they transitively import # ycm_core which we want to be imported ONLY after extra conf # preload has executed. from ycmd import handlers handlers.UpdateUserOptions(options) handlers.KeepSubserversAlive(args.check_interval_seconds) SetUpSignalHandler() atexit.register(handlers.ServerCleanup) pipe = OpenStdPipe() handlers.wsgi_server = PipeServer(handlers.app, pipe) handlers.wsgi_server.Run()
def Main(): args = ParseArguments() if args.stdout is not None: sys.stdout = OpenForStdHandle(args.stdout) if args.stderr is not None: sys.stderr = OpenForStdHandle(args.stderr) SetupLogging(args.log) options, hmac_secret = SetupOptions(args.options_file) # This ensures that ycm_core is not loaded before extra conf # preload was run. YcmCoreSanityCheck() extra_conf_store.CallGlobalExtraConfYcmCorePreloadIfExists() code = ImportAndCheckCore() if code: sys.exit(code) PossiblyDetachFromTerminal() # These can't be top-level imports because they transitively import # ycm_core which we want to be imported ONLY after extra conf # preload has executed. from ycmd import handlers from ycmd.watchdog_plugin import WatchdogPlugin handlers.UpdateUserOptions(options) handlers.SetHmacSecret(hmac_secret) handlers.KeepSubserversAlive(args.check_interval_seconds) SetUpSignalHandler() # Functions registered by the atexit module are called at program termination # in last in, first out order. atexit.register(CleanUpLogfiles, args.stdout, args.stderr, args.keep_logfiles) atexit.register(handlers.ServerCleanup) handlers.app.install( WatchdogPlugin(args.idle_suicide_seconds, args.check_interval_seconds)) handlers.app.install(HmacPlugin(hmac_secret)) CloseStdin() handlers.wsgi_server = StoppableWSGIServer(handlers.app, host=args.host, port=args.port) if sys.stdin is not None: print(f'serving on http://{ handlers.wsgi_server.server_name }:' f'{ handlers.wsgi_server.server_port }') handlers.wsgi_server.serve_forever() handlers.wsgi_server.server_close() handlers.ServerCleanup()
def Main(): args = ParseArguments() if args.stdout is not None: sys.stdout = OpenForStdHandle(args.stdout) if args.stderr is not None: sys.stderr = OpenForStdHandle(args.stderr) SetupLogging(args.log) options, hmac_secret = SetupOptions(args.options_file) # This ensures that ycm_core is not loaded before extra conf # preload was run. YcmCoreSanityCheck() extra_conf_store.CallGlobalExtraConfYcmCorePreloadIfExists() code = CompatibleWithCurrentCore() if code: sys.exit(code) PossiblyDetachFromTerminal() # These can't be top-level imports because they transitively import # ycm_core which we want to be imported ONLY after extra conf # preload has executed. from ycmd import handlers from ycmd.watchdog_plugin import WatchdogPlugin handlers.UpdateUserOptions(options) handlers.SetHmacSecret(hmac_secret) handlers.KeepSubserversAlive(args.check_interval_seconds) SetUpSignalHandler(args.stdout, args.stderr, args.keep_logfiles) handlers.app.install( WatchdogPlugin(args.idle_suicide_seconds, args.check_interval_seconds)) handlers.app.install(HmacPlugin(hmac_secret)) CloseStdin() handlers.wsgi_server = StoppableWSGIServer(handlers.app, host=args.host, port=args.port, threads=30) handlers.wsgi_server.Run()