def run_logger(server_process, name): def logfunc(): while True: try: line = server_process.stdout.readline() except AttributeError: break exitcode = server_process.poll() if (not line) and (exitcode is not None): break if line: line = line.decode("utf8", "replace") log(name, line.rstrip()) daemon_thread(logfunc)
def call_controller(method): daemon_thread(_call_controller, method)
def main(argv=None): if not argv: argv = sys.argv from optparse import OptionParser parser = OptionParser("%prog [options]") parser.add_option("--debug", "-d", help="spam with debug messages", action="store_true", default=False) parser.add_option("-b", "--browser", help="start web browser", dest="browser", default=0, action="store_true") parser.add_option("--config", help="dump JSON of configuration and exit", dest="config", action="store_true", default=0) opts, args = parser.parse_args(argv[1:]) if args: parser.error("wrong number of arguments") # Will exit if opts.config: dump_config() raise SystemExit ensure_user_config() ensure_user_config(USER_BROWSERS_FILE, BROWSERS_FILE) root = root_dir() chdir(root) start_logging() log("Sauce RC", "Sauce RC version %s started" % VERSION) daemon_thread(current_mode.start) daemon_thread(version_thread) daemon_thread(check_ondemand) daemon_thread(get_browsers) atexit.register(cleanup) config = { "/images" : { "tools.staticdir.on" : 1, "tools.staticdir.dir" : join(root, "images"), }, "/css" : { "tools.staticdir.on" : 1, "tools.staticdir.dir" : join(root, "css"), }, "/js" : { "tools.staticdir.on" : 1, "tools.staticdir.dir" : join(root, "js"), }, "/static" : { "tools.staticdir.on" : 1, "tools.staticdir.dir" : join(root, "static"), }, } if opts.browser: daemon_thread(open_browser_when_ready) cherrypy.config.update({"server.socket_host" : "0.0.0.0", "server.socket_port" : SERVER_PORT, "checker.check_skipped_app_config" : False, "log.screen" : False, }) cherrypy.engine.reexec_retry = 20 quickstart(WebServer(), config=config)
def start_logging(): daemon_thread(logger_thread)