Skip to content

Commit

Permalink
Allow to stay on the cwd when started as a daemon
Browse files Browse the repository at this point in the history
Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
  • Loading branch information
rtobar committed Sep 5, 2017
1 parent 9f4464f commit 2a5aa06
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dfms/manager/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def addCommonOptions(parser, defaultPort):
dest="maxreqsize", help="The maximum allowed HTTP request size, in MB", default=10)
parser.add_option("-d", "--daemon", action="store_true",
dest="daemon", help="Run as daemon", default=False)
parser.add_option( "--cwd", action="store_true",
dest="cwd", help="Stay in the current working directory (when used with -d)", default=False)
parser.add_option("-s", "--stop", action="store_true",
dest="stop", help="Stop an instance running as daemon", default=False)
parser.add_option("-v", "--verbose", action="count",
Expand Down Expand Up @@ -123,7 +125,9 @@ def start(options, parser):
createDirIfMissing(pidDir)
pidfile = os.path.join(pidDir, "dfms%s.pid" % (options.dmAcronym))

with daemon.DaemonContext(pidfile=PIDLockFile(pidfile, 1), files_preserve=[fileHandler.stream]):
working_dir = '.' if options.cwd else '/'
with daemon.DaemonContext(pidfile=PIDLockFile(pidfile, 1), files_preserve=[fileHandler.stream],
working_directory=working_dir):
launchServer(options)

# Stop daemon?
Expand Down

0 comments on commit 2a5aa06

Please sign in to comment.