def run_daemon(args):
ctx = daemon.DaemonContext(
working_directory=args.working_directory,
pidfile=lockfile.LockFile(args.pidfile),
stdout=open_io_redirect_file(args.stdout),
stderr=open_io_redirect_file(args.stderr),
)
if args.command == "status":
sys,exit(1 if ctx.is_open else 0)
elif args.command == "stop":
ctx.close()
elif args.command == "start":
with ctx:
PyPush.web.main.main(
False, # I hereby force debug-less mode on the daemon.
args.host, args.port,
args.db_uri,
args.ble_driver, args.ble_device
)
else:
raise Exception("Unexpected daemon command {!r}".format(args.command))
评论列表
文章目录