Package: mini-dinstall
Version: 0.6.22+psha0
Severity: wishlist
Tags: patch
Add --foreground option (like --background but don't detach)
for use under service supervisors (runit).
Both plain and git patches are attached
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.22-2-686 (SMP w/2 CPU cores)
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8) (ignored: LC_ALL
set to ru_RU.UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages mini-dinstall depends on:
ii apt-utils 0.7.9 APT utility programs
ii python 2.4.4-6 An interactive high-level object-o
ii python-apt 0.7.3.1+b1 Python interface to libapt-pkg
ii python-support 0.7.5 automated rebuilding support for p
mini-dinstall recommends no packages.
-- no debconf information
commit 455fb0c8464a8619ff65276c9f44f55c17eda3ec
Author: Pavel Shramov <[EMAIL PROTECTED]>
Date: Thu Nov 15 21:28:57 2007 +0300
added %m to subject (success_logger)
diff --git a/mini-dinstall b/mini-dinstall
index 0a871d9..5a28884 100755
--- a/mini-dinstall
+++ b/mini-dinstall
@@ -195,7 +195,7 @@ class SubjectSpecifyingLoggingSMTPHandler(logging.handlers.SMTPHandler):
apply(logging.handlers.SMTPHandler.__init__, [self] + list(args) + ['dummy'], kwargs)
def getSubject(self, record):
- return re.sub('%l', record.levelname, self._subject)
+ return self._subject.replace('%l', record.levelname).replace('%m', record.msg.split('\n')[0])
if not (configp.has_option('DEFAULT', 'mail_log_level') and configp.get('DEFAULT', 'mail_log_level') == 'NONE'):
if configp.has_option('DEFAULT', 'mail_log_level'):
@@ -707,7 +707,7 @@ class ArchiveDir:
if self._mail_on_success:
self._success_logger = logging.Logger("mini-dinstall." + self._name)
self._success_logger.setLevel(logging.DEBUG)
- handler = SubjectSpecifyingLoggingSMTPHandler('mini-dinstall success notice', mail_server, 'Mini-Dinstall <[EMAIL PROTECTED]>' % (getpass.getuser(),socket.getfqdn()), [mail_to])
+ handler = SubjectSpecifyingLoggingSMTPHandler('mini-dinstall: %m', mail_server, 'Mini-Dinstall <[EMAIL PROTECTED]>' % (getpass.getuser(),socket.getfqdn()), [mail_to])
handler.setLevel(logging.DEBUG)
self._success_logger.addHandler(handler)
self._clean_targets = []
>From 6463dcd967d8f1e55a3d856e31d9fcb294772d97 Mon Sep 17 00:00:00 2001
From: Pavel Shramov <[EMAIL PROTECTED]>
Date: Sun, 11 Nov 2007 13:32:16 +0300
Subject: [PATCH] add --foreground option
---
mini-dinstall | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/mini-dinstall b/mini-dinstall
index 6abada6..0a871d9 100755
--- a/mini-dinstall
+++ b/mini-dinstall
@@ -80,6 +80,7 @@ def usage(ecode, ver_only=None):
print " -q, --quiet\t\tDisplay less information"
print " -c, --config=FILE\tParse configuration info from FILE"
print " -d, --debug\t\tOutput information to stdout as well as log"
+ print " -f, --foreground\tRun daemon in foreground"
print " --no-log\t\tDon't write information to log file"
print " -n, --no-act\t\tDon't actually perform changes"
print " -b, --batch\t\tDon't daemonize; run once, then exit"
@@ -90,8 +91,8 @@ def usage(ecode, ver_only=None):
sys.exit(ecode)
try:
- opts, args = getopt.getopt(sys.argv[1:], 'vqc:dnbrk',
- ['verbose', 'quiet', 'config=', 'debug',
'no-log',
+ opts, args = getopt.getopt(sys.argv[1:], 'vqc:dfnbrk',
+ ['verbose', 'quiet', 'config=', 'debug',
'foreground', 'no-log',
'no-act', 'batch', 'run', 'kill', 'help',
'version', ])
except getopt.GetoptError, e:
sys.stderr.write("Error reading arguments: %s\n" % e)
@@ -117,6 +118,7 @@ run_mode = 0
kill_mode = 0
no_log = 0
batch_mode = 0
+foreground_mode = 0
custom_config_files = 0
for key, val in opts:
if key in ('-v', '--verbose'):
@@ -142,6 +144,8 @@ for key, val in opts:
no_log = 1
elif key in ('-b', '--batch'):
batch_mode = 1
+ elif key in ('-f', '--foreground'):
+ foreground_mode = 1
elif key in ('-r', '--run'):
run_mode = 1
elif key in ('-k', '--kill'):
@@ -1479,7 +1483,7 @@ if not no_act:
lockfile = open(lockfilename, 'w')
lockfile.close()
-if not batch_mode:
+if not batch_mode and not foreground_mode:
# daemonize
logger.debug("Daemonizing...")
if os.fork() == 0:
@@ -1500,6 +1504,9 @@ if not batch_mode:
sys.stderr = open("/dev/null")
logger.debug("Finished daemonizing (pid %s)" % (os.getpid(),))
+if foreground_mode:
+ logger.debug("Running in foreground...")
+
lockfile = open(lockfilename, 'w')
lockfile.write("%s" % (os.getpid(),))
lockfile.close()
--
1.5.3.5