From afb4c816cc713e27cf44334ddce3608a345a4356 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 19 Jul 2020 10:17:39 +0300 Subject: refactor: use functions for starting/stopping daemons in ewww.py --- ewww.py | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/ewww.py b/ewww.py index 4f06b47..3eb6e97 100644 --- a/ewww.py +++ b/ewww.py @@ -83,30 +83,12 @@ def start_server(ctx, filename=None): config = yaml.safe_dump(config) _write(filename, config) - _run( - ctx, - [ - "/usr/sbin/daemonize", - "-c", - os.getcwd(), - "-p", - "ewww.pid", - "-o", - "ewww.stdout", - "-e", - "ewww.stderr", - _binary("ewww"), - filename, - ], - ) - _run_exit(ctx, 0) - - ctx["pid"] = int(open("ewww.pid").read().strip()) + start_daemon(ctx, "ewww", [_binary("ewww"), filename]) # Stop previously started server. def stop_server(ctx): - os.kill(ctx["pid"], signal.SIGKILL) + stop_daemon(ctx, "ewww") # Make a HTTP request. -- cgit v1.2.1