calibre-server: Use cherrypy plugin for --pidfile instead of custom code

This commit is contained in:
Kovid Goyal 2010-10-18 11:18:53 -06:00
parent 6143bdcce4
commit 6b7962c2b2

View File

@ -5,7 +5,7 @@ __license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import os, sys import sys
from threading import Thread from threading import Thread
from calibre.library.server import server_config as config from calibre.library.server import server_config as config
@ -48,8 +48,8 @@ def main(args=sys.argv):
d = Daemonizer(cherrypy.engine) d = Daemonizer(cherrypy.engine)
d.subscribe() d.subscribe()
if opts.pidfile is not None: if opts.pidfile is not None:
with open(opts.pidfile, 'wb') as f: from cherrypy.process.plugins import PIDFile
f.write(str(os.getpid())) PIDFile(cherrypy.engine, opts.pidfile).subscribe()
cherrypy.log.screen = True cherrypy.log.screen = True
from calibre.utils.config import prefs from calibre.utils.config import prefs
if opts.with_library is None: if opts.with_library is None: