Fix removal of --daemonize option caused standalone calibre-server.exe to not work on Windows and macOS

This commit is contained in:
Kovid Goyal 2017-06-23 14:32:56 +05:30
parent 0ada3549c1
commit 0d242c48ee
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -335,7 +335,7 @@ def main(args=sys.argv):
libraries=[prefs['library_path']] libraries=[prefs['library_path']]
if opts.auto_reload: if opts.auto_reload:
if opts.daemonize: if getattr(opts, 'daemonize', False):
raise SystemExit('Cannot specify --auto-reload and --daemonize at the same time') raise SystemExit('Cannot specify --auto-reload and --daemonize at the same time')
from calibre.srv.auto_reload import auto_reload, NoAutoReload from calibre.srv.auto_reload import auto_reload, NoAutoReload
try: try:
@ -346,7 +346,7 @@ def main(args=sys.argv):
opts.auto_reload_port=int(os.environ.get('CALIBRE_AUTORELOAD_PORT', 0)) opts.auto_reload_port=int(os.environ.get('CALIBRE_AUTORELOAD_PORT', 0))
opts.allow_console_print = 'CALIBRE_ALLOW_CONSOLE_PRINT' in os.environ opts.allow_console_print = 'CALIBRE_ALLOW_CONSOLE_PRINT' in os.environ
server=Server(libraries, opts) server=Server(libraries, opts)
if opts.daemonize: if getattr(opts, 'daemonize', False):
if not opts.log and not iswindows: if not opts.log and not iswindows:
raise SystemExit('In order to daemonize you must specify a log file, you can use /dev/stdout to log to screen even as a daemon') raise SystemExit('In order to daemonize you must specify a log file, you can use /dev/stdout to log to screen even as a daemon')
daemonize() daemonize()
@ -354,7 +354,7 @@ def main(args=sys.argv):
with lopen(opts.pidfile, 'wb') as f: with lopen(opts.pidfile, 'wb') as f:
f.write(str(os.getpid())) f.write(str(os.getpid()))
signal.signal(signal.SIGTERM, lambda s,f: server.stop()) signal.signal(signal.SIGTERM, lambda s,f: server.stop())
if not opts.daemonize and not iswindows: if not getattr(opts, 'daemonize', False) and not iswindows:
signal.signal(signal.SIGHUP, lambda s,f: server.stop()) signal.signal(signal.SIGHUP, lambda s,f: server.stop())
# Needed for dynamic cover generation, which uses Qt for drawing # Needed for dynamic cover generation, which uses Qt for drawing
from calibre.gui2 import ensure_app, load_builtin_fonts from calibre.gui2 import ensure_app, load_builtin_fonts