def __init__(self, libraries, opts): log = access_log = None log_size = opts.max_log_size * 1024 * 1024 if opts.log: log = RotatingLog(opts.log, max_size=log_size) if opts.access_log: access_log = RotatingLog(opts.access_log, max_size=log_size) self.handler = Handler(libraries, opts) if opts.custom_list_template: with lopen(os.path.expanduser(opts.custom_list_template), 'rb') as f: self.handler.router.ctx.custom_list_template = json.load(f) if opts.search_the_net_urls: with lopen(os.path.expanduser(opts.search_the_net_urls), 'rb') as f: self.handler.router.ctx.search_the_net_urls = json.load(f) plugins = [] if opts.use_bonjour: plugins.append( BonJour(wait_for_stop=max(0, opts.shutdown_timeout - 0.2))) self.loop = ServerLoop(create_http_handler(self.handler.dispatch), opts=opts, log=log, access_log=access_log, plugins=plugins) self.handler.set_log(self.loop.log) self.handler.set_jobs_manager(self.loop.jobs_manager) self.serve_forever = self.loop.serve_forever self.stop = self.loop.stop if is_running_from_develop: from calibre.utils.rapydscript import compile_srv compile_srv()
def __init__(self, libraries, opts): log = access_log = None log_size = opts.max_log_size * 1024 * 1024 if opts.log: log = RotatingLog(opts.log, max_size=log_size) if opts.access_log: access_log = RotatingLog(opts.access_log, max_size=log_size) self.handler = Handler(libraries, opts) if opts.custom_list_template: with lopen(opts.custom_list_template, 'rb') as f: self.handler.router.ctx.custom_list_template = json.load(f) plugins = [] if opts.use_bonjour: plugins.append(BonJour()) self.loop = ServerLoop( create_http_handler(self.handler.dispatch), opts=opts, log=log, access_log=access_log, plugins=plugins) self.handler.set_log(self.loop.log) self.handler.set_jobs_manager(self.loop.jobs_manager) self.serve_forever = self.loop.serve_forever self.stop = self.loop.stop if is_running_from_develop: from calibre.utils.rapydscript import compile_srv compile_srv()
def __init__(self, libraries, opts): log = None if opts.log: log = RotatingLog(opts.log, max_size=opts.max_log_size) self.handler = Handler(libraries, opts) plugins = [] if opts.use_bonjour: plugins.append(BonJour()) self.loop = ServerLoop(create_http_handler(self.handler.dispatch), opts=opts, log=log, plugins=plugins) self.handler.set_log(self.loop.log) self.serve_forever = self.loop.serve_forever self.stop = self.loop.stop
def __init__(self, libraries, opts): log = None if opts.log: log = RotatingLog(opts.log, max_size=opts.max_log_size) self.handler = Handler(libraries, opts) plugins = [] if opts.use_bonjour: plugins.append(BonJour()) self.loop = ServerLoop(create_http_handler(self.handler.dispatch), opts=opts, log=log, plugins=plugins) self.handler.set_log(self.loop.log) self.serve_forever = self.loop.serve_forever self.stop = self.loop.stop _df = os.environ.get('CALIBRE_DEVELOP_FROM', None) if _df and os.path.exists(_df): from calibre.utils.rapydscript import compile_srv compile_srv()
def __init__(self, libraries, opts): log = access_log = None log_size = opts.max_log_size * 1024 * 1024 if opts.log: log = RotatingLog(opts.log, max_size=log_size) if opts.access_log: access_log = RotatingLog(opts.access_log, max_size=log_size) self.handler = Handler(libraries, opts) plugins = [] if opts.use_bonjour: plugins.append(BonJour()) self.loop = ServerLoop(create_http_handler(self.handler.dispatch), opts=opts, log=log, access_log=access_log, plugins=plugins) self.handler.set_log(self.loop.log) self.handler.set_jobs_manager(self.loop.jobs_manager) self.serve_forever = self.loop.serve_forever self.stop = self.loop.stop if is_running_from_develop: from calibre.utils.rapydscript import compile_srv compile_srv()