Commit 0be40768 authored by Nick Mathewson's avatar Nick Mathewson 👉
Browse files

r17161@catbus: nickm | 2007-12-14 16:27:35 -0500

 Implement pid-file support.


svn:r12818
parent 0840d322
......@@ -6,6 +6,9 @@
# pathnames are created under this directory
RUN_IN_DIR = "~/run/"
# Either a file in which to write our pid, or None
PIDFILE = "bridgedb.pid"
# Files from which we read descriptors on start and SIGHUP
# XXXX SIGHUP not implemented.
BRIDGE_FILES = [ "./cached-descriptors", "./cached-descriptors.new" ]
......
......@@ -21,6 +21,7 @@ class Conf:
CONFIG = Conf(
RUN_IN_DIR = ".",
PIDFILE = "bridgedb.pid",
BRIDGE_FILES = [ "./cached-descriptors", "./cached-descriptors.new" ],
BRIDGE_PURPOSE = "bridge",
DB_FILE = "./bridgedist.db",
......@@ -96,7 +97,7 @@ def _handleSIGHUP(*args):
def startup(cfg):
cfg.BRIDGE_FILES = [ os.path.expanduser(fn) for fn in cfg.BRIDGE_FILES ]
for key in ("RUN_IN_DIR", "DB_FILE", "DB_LOG_FILE", "MASTER_KEY_FILE",
"HTTPS_CERT_FILE", "HTTPS_KEY_FILE"):
"HTTPS_CERT_FILE", "HTTPS_KEY_FILE", "PIDFILE"):
v = getattr(cfg, key)
if v:
setattr(cfg, key, os.path.expanduser(v))
......@@ -104,6 +105,11 @@ def startup(cfg):
if cfg.RUN_IN_DIR:
os.chdir(cfg.RUN_IN_DIR)
if cfg.PIDFILE:
f = open(cfg.PIDFILE, 'w')
f.write("%s\n"%os.getpid())
f.close()
key = getKey(cfg.MASTER_KEY_FILE)
dblogfile = None
emailDistributor = ipDistributor = None
......@@ -172,6 +178,8 @@ def startup(cfg):
baseStore.close()
if dblogfile is not None:
dblogfile.close()
if cfg.PIDFILE:
os.unlink(cfg.PIDFILE)
def run():
if len(sys.argv) != 2:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment