Correct exit code when no twistd.pid file
This commit is contained in:
parent
e16b53817e
commit
c4cd4db30e
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import functools
|
import functools
|
||||||
|
import click
|
||||||
|
|
||||||
class ServerError(Exception):
|
class ServerError(Exception):
|
||||||
def __init__(self, message, relay):
|
def __init__(self, message, relay):
|
||||||
|
@ -47,7 +48,11 @@ class KeyFormatError(Exception):
|
||||||
class ReflectionAttack(Exception):
|
class ReflectionAttack(Exception):
|
||||||
"""An attacker (or bug) reflected our outgoing message back to us."""
|
"""An attacker (or bug) reflected our outgoing message back to us."""
|
||||||
|
|
||||||
class UsageError(Exception):
|
# Click needs to receive click.UsageError instances to "do the right
|
||||||
|
# thing", which is print the error and exit -- perhaps it would be
|
||||||
|
# better just to re-export click.UsageError here? Or use
|
||||||
|
# click.UsageError throughout the codebase?
|
||||||
|
class UsageError(click.UsageError, Exception):
|
||||||
"""The programmer did something wrong."""
|
"""The programmer did something wrong."""
|
||||||
|
|
||||||
class WormholeClosedError(UsageError):
|
class WormholeClosedError(UsageError):
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
import os, time
|
import os, time
|
||||||
|
from ..errors import UsageError
|
||||||
from twisted.python import usage
|
from twisted.python import usage
|
||||||
from twisted.scripts import twistd
|
from twisted.scripts import twistd
|
||||||
|
|
||||||
|
@ -38,8 +39,9 @@ def kill_server():
|
||||||
try:
|
try:
|
||||||
f = open("twistd.pid", "r")
|
f = open("twistd.pid", "r")
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
print("Unable to find twistd.pid . Is this really a server directory?")
|
raise UsageError(
|
||||||
return
|
"Unable to find 'twistd.pid' -- is this really a server directory?"
|
||||||
|
)
|
||||||
pid = int(f.read().strip())
|
pid = int(f.read().strip())
|
||||||
f.close()
|
f.close()
|
||||||
os.kill(pid, 15)
|
os.kill(pid, 15)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user