[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r12818: Implement pid-file support. (in bridgedb/trunk: . lib/bridgedb)
Author: nickm
Date: 2007-12-14 16:27:37 -0500 (Fri, 14 Dec 2007)
New Revision: 12818
Modified:
bridgedb/trunk/
bridgedb/trunk/bridgedb.conf
bridgedb/trunk/lib/bridgedb/Main.py
Log:
r17161@catbus: nickm | 2007-12-14 16:27:35 -0500
Implement pid-file support.
Property changes on: bridgedb/trunk
___________________________________________________________________
svk:merge ticket from /bridgedb/trunk [r17161] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: bridgedb/trunk/bridgedb.conf
===================================================================
--- bridgedb/trunk/bridgedb.conf 2007-12-14 21:24:43 UTC (rev 12817)
+++ bridgedb/trunk/bridgedb.conf 2007-12-14 21:27:37 UTC (rev 12818)
@@ -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" ]
Modified: bridgedb/trunk/lib/bridgedb/Main.py
===================================================================
--- bridgedb/trunk/lib/bridgedb/Main.py 2007-12-14 21:24:43 UTC (rev 12817)
+++ bridgedb/trunk/lib/bridgedb/Main.py 2007-12-14 21:27:37 UTC (rev 12818)
@@ -21,6 +21,7 @@
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 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 @@
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 @@
baseStore.close()
if dblogfile is not None:
dblogfile.close()
+ if cfg.PIDFILE:
+ os.unlink(cfg.PIDFILE)
def run():
if len(sys.argv) != 2: