From 2f100cd2a78a0f91022bc4a895007975181cf353 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 11 Dec 2007 12:02:46 +0000 Subject: [PATCH] various cosmetic changes NOTE. I'm leaving vsliver_vs.py untouched However, in set_resources, most of the calls to the lower level (vserver/vserverimpl) methods are called unprotected by a try/except If any of this fails, then the exception gets caught in accounts:_run only and this might prevent correct operations to make things worse, in such a case the error messages printed by vserverimpl might get lost in daemon mode So a cleanup in this area might be most useful --- accounts.py | 2 +- logger.py | 3 ++- nm.init | 7 ++++--- tools.py | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/accounts.py b/accounts.py index 3074e41..3711a0d 100644 --- a/accounts.py +++ b/accounts.py @@ -81,7 +81,7 @@ class Account: def configure(self, rec): """Write to my authorized_keys file.""" - logger.verbose('in accounts:configure') + logger.verbose('in accounts:configure for %s'%self.name) new_keys = rec['keys'] if new_keys != self.keys: self.keys = new_keys diff --git a/logger.py b/logger.py index bfc416b..0b083ca 100644 --- a/logger.py +++ b/logger.py @@ -21,6 +21,7 @@ LOG_VERBOSE=2 LOG_LEVEL=1 def set_level(level): + global LOG_LEVEL assert level in [LOG_NONE,LOG_NODE,LOG_VERBOSE] LOG_LEVEL=level @@ -56,7 +57,7 @@ def log_slivers (data): import pprint, time try: f=open(LOG_SLIVERS,'w') - now=time.strftime("GetSlivers stored at %H:%M:%S", time.localtime()) + now=time.strftime("GetSlivers stored on %Y.%m.%d at %H:%M:%S", time.localtime()) f.write(now+'\n') pp=pprint.PrettyPrinter(stream=f,indent=2) pp.pprint(data) diff --git a/nm.init b/nm.init index 7fb3154..4ae386d 100755 --- a/nm.init +++ b/nm.init @@ -15,7 +15,8 @@ fi nm=${NM-"python /usr/share/NodeManager/nm.py"} prog="Node Manager" -restartoptions= +options=${OPTIONS-"-d -s"} +restartoptions=${RESTARTOPTIONS-"-d"} pidfile=${PIDFILE-/var/run/nm.pid} lockfile=${LOCKFILE-/var/lock/subsys/nm} RETVAL=0 @@ -32,7 +33,7 @@ do_start() start() { - do_start ${OPTIONS-"-d -s"} + do_start $options } stop() @@ -51,7 +52,7 @@ stop() restart() { stop - do_start ${OPTIONS-"-d"} + do_start $restartoptions } diff --git a/tools.py b/tools.py index f4496e1..49441bd 100644 --- a/tools.py +++ b/tools.py @@ -36,7 +36,8 @@ def daemon(): os.umask(0) devnull = os.open(os.devnull, os.O_RDWR) os.dup2(devnull, 0) - crashlog = os.open('/root/nm.stderr', os.O_RDWR | os.O_APPEND | os.O_CREAT, 0644) + # xxx fixme - this is just to make sure that nothing gets stupidly lost - should use devnull + crashlog = os.open('/var/log/nm.daemon', os.O_RDWR | os.O_APPEND | os.O_CREAT, 0644) os.dup2(crashlog, 1) os.dup2(crashlog, 2) -- 2.43.0