[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] Server tweaks: Create parent dirs as needed; accept add...
Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv32349/lib/mixminion/server
Modified Files:
EventStats.py ServerMain.py
Log Message:
Server tweaks: Create parent dirs as needed; accept additional command line options. [Bug 20]
Index: EventStats.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/EventStats.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- EventStats.py 25 Nov 2003 02:15:14 -0000 1.10
+++ EventStats.py 25 Nov 2003 03:42:31 -0000 1.11
@@ -226,6 +226,7 @@
LOG.debug("Flushing statistics log")
if now is None: now = time()
+ #XXXX006 dump boilerplate when starting new file.
f = open(self.historyFilename, 'a')
self.dump(f, now)
f.close()
@@ -305,6 +306,10 @@
if config['Server']['LogStats']:
LOG.info("Enabling statistics logging")
statsfile = config.getStatsFile()
+ if not os.path.exists(os.path.split(statsfile)[0]):
+ # create parent if needed.
+ os.makedirs(os.path.split(statsfile)[0], 0700)
+
workfile = os.path.join(config.getWorkDir(), "stats.tmp")
#XXXX006 ensure parent.
log = EventLog(
Index: ServerMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerMain.py,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -d -r1.102 -r1.103
--- ServerMain.py 25 Nov 2003 02:15:14 -0000 1.102
+++ ServerMain.py 25 Nov 2003 03:42:31 -0000 1.103
@@ -646,12 +646,20 @@
# The pid/lock file.
self.pidFile = config.getPidFile()
+ if not os.path.exists(os.path.split(self.pidFile)[0]):
+ # create parent if needed.
+ os.makedirs(os.path.split(self.pidFile)[0], 0700)
self.lockFile = Lockfile(self.pidFile)
try:
self.lockFile.acquire(mode=0644)
except LockfileLocked:
raise UIError("Another server seems to be running.")
+ # Create directories as needed; homeDir already created.
+ createPrivateDir(config.getWorkDir())
+ createPrivateDir(config.getKeyDir())
+ createPrivateDir(config.getQueueDir())
+
# Try to read the keyring. If we have a pre-0.0.4 version of
# mixminion, we might have some bad server descriptors lying
# around. If so, tell the user to run server-upgrade.
@@ -987,12 +995,17 @@
Otherwise, find and parse the configuration file.
"""
global _QUIET_OPT
- options, args = getopt.getopt(args, "hQf:", ["help", "quiet", "config="])
+ options, args = getopt.getopt(args, "hQf:",
+ ["help", "quiet", "config=",
+ "daemon", "nodaemon", "echo", "severity="])
if args:
print >>sys.stderr, "No arguments expected."
print usage
sys.exit(0)
configFile = None
+ forceDaemon = None
+ echo = 0
+ severity = None
for o,v in options:
if o in ('-h', '--help'):
print usage
@@ -1001,8 +1014,33 @@
configFile = v
elif o in ('-Q', '--quiet'):
_QUIET_OPT = 1
+ elif o == '--nodaemon':
+ forceDaemon = 0
+ elif o == '--daemon':
+ forceDaemon = 1
+ elif o == '--echo':
+ echo = 1
+ elif o == '--severity':
+ try:
+ severity = mixminion.Config._parseSeverity(v)
+ except mixminion.Config.ConfigError, e:
+ raise UIError(str(e))
- return readConfigFile(configFile)
+ #DOCDOC
+ config = readConfigFile(configFile)
+ if forceDaemon == 0 and not _QUIET_OPT:
+ echo = 1
+ if echo:
+ config['Server']['EchoMessages'] = 2#DOCDOC
+ elif _QUIET_OPT:
+ config['Server']['EchoMessages'] = 0
+ if forceDaemon is not None:
+ config['Server']['Daemon'] = forceDaemon
+ if severity is not None:
+ config['Server']['LogLevel'] = severity
+
+ return config
+
def readConfigFile(configFile):
"""Given a filename from the command line (or None if the user didn't
@@ -1041,6 +1079,10 @@
-h, --help: Print this usage message and exit.
-f <file>, --config=<file> Use a configuration file other than the default.
-Q, --quiet Suppress the verbose server startup.
+ --daemon Run in daemon mode, overriding the config file.
+ --nodaemon Run in nondaemon mode, overriding the config file.
+ --echo Write all log messages to stderr.
+ --severity=<level> Override the configured log severity.
""".strip()
def runServer(cmd, args):