mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Start work on auto-reload
This commit is contained in:
parent
4d87cb01ff
commit
7511d0009d
@ -91,6 +91,11 @@ program will be used.
|
|||||||
help=_('Run process in background as a daemon. No effect on Windows.'))
|
help=_('Run process in background as a daemon. No effect on Windows.'))
|
||||||
parser.add_option('--pidfile', default=None,
|
parser.add_option('--pidfile', default=None,
|
||||||
help=_('Write process PID to the specified file'))
|
help=_('Write process PID to the specified file'))
|
||||||
|
parser.add_option(
|
||||||
|
'--auto-reload', default=False, action='store_true',
|
||||||
|
help=_('Automatically reload server when source code changes. Useful'
|
||||||
|
' for development. You should also specify a small value for the'
|
||||||
|
' shutdown timeout.'))
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
@ -104,6 +109,16 @@ def main(args=sys.argv):
|
|||||||
if not prefs['library_path']:
|
if not prefs['library_path']:
|
||||||
raise SystemExit(_('You must specify at least one calibre library'))
|
raise SystemExit(_('You must specify at least one calibre library'))
|
||||||
libraries = [prefs['library_path']]
|
libraries = [prefs['library_path']]
|
||||||
|
|
||||||
|
if opts.auto_reload:
|
||||||
|
if opts.daemonize:
|
||||||
|
raise SystemExit('Cannot specify --auto-reload and --daemonize at the same time')
|
||||||
|
from calibre.srv.auto_reload import auto_reload, NoAutoReload
|
||||||
|
try:
|
||||||
|
from calibre.utils.logging import default_log
|
||||||
|
return auto_reload(default_log)
|
||||||
|
except NoAutoReload as e:
|
||||||
|
raise SystemExit(e.message)
|
||||||
server = Server(libraries, opts)
|
server = Server(libraries, opts)
|
||||||
if opts.daemonize:
|
if opts.daemonize:
|
||||||
if not opts.log and not iswindows:
|
if not opts.log and not iswindows:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user