diff options
| -rwxr-xr-x | mini-dinstall | 13 |
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() |
