summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarPavel Shramov <psha@qwe.ipib.msu.ru>2007-11-11 13:32:16 +0300
committerLibravatarUnit 193 <unit193@ubuntu.com>2019-07-13 21:10:07 -0400
commitdc4416da24b9852c32a962743fc009381af3d466 (patch)
tree80725958a4e52a64b8f9785ccc1a55b86be91a80
parentf63c0b19ec5b9b4fe25793eb0bcf43586cc3dd68 (diff)
Add --foreground option
Closes: #451947
-rwxr-xr-xmini-dinstall13
1 files changed, 10 insertions, 3 deletions
diff --git a/mini-dinstall b/mini-dinstall
index c760dc9..27039af 100755
--- a/mini-dinstall
+++ b/mini-dinstall
@@ -97,6 +97,7 @@ Options:
-q, --quiet Display less information
-c, --config=FILE Parse configuration info from FILE
-d, --debug Output information to stdout as well as log
+ -f, --foreground Run daemon in foreground
--no-log Don't write information to log file
-n, --no-act Don't actually perform changes
-b, --batch Don't daemonize; run once, then exit
@@ -109,8 +110,8 @@ Options:
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', 'no-db', 'help', 'version'])
except getopt.GetoptError as e:
sys.stderr.write("Error reading arguments: %s\n" % e)
@@ -136,6 +137,7 @@ run_mode = False
kill_mode = False
nodb_mode = False
no_log = False
+foreground_mode = False
batch_mode = False
custom_config_files = False
@@ -163,6 +165,8 @@ for (key, value) in opts:
no_log = True
elif key in ('-b', '--batch'):
batch_mode = True
+ elif key in ('-f', '--foreground'):
+ foreground_mode = True
elif key in ('-r', '--run'):
run_mode = True
elif key in ('-k', '--kill'):
@@ -1528,7 +1532,7 @@ if not no_act:
lockfile = open(lockfilename, 'w')
lockfile.close()
-if not batch_mode:
+if not (batch_mode or foreground_mode):
# daemonize
logger.debug("Daemonizing...")
if os.fork() == 0:
@@ -1549,6 +1553,9 @@ if not batch_mode:
sys.stderr = open("/dev/null")
logger.debug("Finished daemonizing (pid %d)" % os.getpid())
+if foreground_mode:
+ logger.debug("Running in foreground...")
+
lockfile = open(lockfilename, 'w')
lockfile.write(str(os.getpid()))
lockfile.close()