From 6d00576ee4bf7df8fca63596950b976b6570fa9a Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 23 Jun 2016 18:25:02 -0700 Subject: [PATCH] server-stop: ignore missing twistd.pid I changed my mind, it's actually easier if 'wormhole-server stop' (and 'restart') does *not* throw an error when there wasn't already a server running in that directory. Specifically that lets me use 'restart' as an idempotent "make sure a server is running" command. --- src/wormhole/server/cmd_server.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wormhole/server/cmd_server.py b/src/wormhole/server/cmd_server.py index 6c3c6cc..f4fdac5 100644 --- a/src/wormhole/server/cmd_server.py +++ b/src/wormhole/server/cmd_server.py @@ -1,6 +1,5 @@ from __future__ import print_function, unicode_literals import os, time -import click from twisted.python import usage from twisted.scripts import twistd @@ -39,9 +38,9 @@ def kill_server(): try: f = open("twistd.pid", "r") except EnvironmentError: - raise click.UsageError( - "Unable to find 'twistd.pid' -- is this really a server directory?" - ) + print("Unable to find twistd.pid: is this really a server directory?") + print("oh well, ignoring 'stop'") + return pid = int(f.read().strip()) f.close() os.kill(pid, 15)