diff --git a/pscheduler-server/pscheduler-server/daemons/archiver.raw b/pscheduler-server/pscheduler-server/daemons/archiver.raw index 3c2e916c9..7fbbdf825 100755 --- a/pscheduler-server/pscheduler-server/daemons/archiver.raw +++ b/pscheduler-server/pscheduler-server/daemons/archiver.raw @@ -14,7 +14,6 @@ import signal import threading import time -import daemon import pscheduler from dateutil.tz import tzlocal @@ -27,17 +26,6 @@ pscheduler.set_graceful_exit() opt_parser = optparse.OptionParser() -# Daemon-related options - -opt_parser.add_option("--daemon", - help="Daemonize", - action="store_true", - dest="daemon", default=False) -opt_parser.add_option("--pid-file", - help="Location of PID file", - action="store", type="string", dest="pidfile", - default=None) - # Program options opt_parser.add_option("-a", "--archive-defaults", @@ -1123,13 +1111,4 @@ def main_program(): -with pscheduler.PidFile(options.pidfile) as pidfile: - if options.daemon: - with daemon.DaemonContext(pidfile=pidfile): - # Any return of True means run it again. - while main_program(): - pass - else: - # Ibid. - while main_program(): - pass +main_program() diff --git a/pscheduler-server/pscheduler-server/daemons/runner b/pscheduler-server/pscheduler-server/daemons/runner index aa74e664e..c5fec296c 100755 --- a/pscheduler-server/pscheduler-server/daemons/runner +++ b/pscheduler-server/pscheduler-server/daemons/runner @@ -3,7 +3,6 @@ # Execute runs of tasks and put the results into the database. # -import daemon import datetime import errno import multiprocessing @@ -26,17 +25,6 @@ pscheduler.set_graceful_exit() opt_parser = optparse.OptionParser() -# Daemon-related options - -opt_parser.add_option("--daemon", - help="Daemonize", - action="store_true", - dest="daemon", default=False) -opt_parser.add_option("--pid-file", - help="Location of PID file", - action="store", type="string", dest="pidfile", - default=None) - # Program options opt_parser.add_option("-d", "--dsn", @@ -970,9 +958,4 @@ def main_program(): db.close() -with pscheduler.PidFile(options.pidfile) as pidfile: - if options.daemon: - with daemon.DaemonContext(pidfile=pidfile): - main_program() - else: - main_program() +main_program() diff --git a/pscheduler-server/pscheduler-server/daemons/scheduler b/pscheduler-server/pscheduler-server/daemons/scheduler index cd95f419b..85912224c 100755 --- a/pscheduler-server/pscheduler-server/daemons/scheduler +++ b/pscheduler-server/pscheduler-server/daemons/scheduler @@ -4,7 +4,6 @@ # import copy -import daemon import datetime import errno import optparse @@ -25,17 +24,6 @@ random.seed() opt_parser = optparse.OptionParser() -# Daemon-related options - -opt_parser.add_option("--daemon", - help="Daemonize", - action="store_true", - dest="daemon", default=False) -opt_parser.add_option("--pid-file", - help="Location of PID file", - action="store", type="string", dest="pidfile", - default=None) - # Program options opt_parser.add_option("-d", "--dsn", @@ -1028,9 +1016,4 @@ def main_program(): -with pscheduler.PidFile(options.pidfile) as pidfile: - if options.daemon: - with daemon.DaemonContext(pidfile=pidfile): - main_program() - else: - main_program() +main_program() diff --git a/pscheduler-server/pscheduler-server/daemons/service-template.raw b/pscheduler-server/pscheduler-server/daemons/service-template.raw index ebebd0ce2..6d463879c 100644 --- a/pscheduler-server/pscheduler-server/daemons/service-template.raw +++ b/pscheduler-server/pscheduler-server/daemons/service-template.raw @@ -3,28 +3,30 @@ Description=pScheduler server - __PROG__ [Service] -Type=simple +Type=exec User=__PSUSER__ Group=__PSUSER__ PermissionsStartOnly=true -PIDFile=__RUNDIR__/__PROG__/pid LimitNOFILE=32768 LimitNPROC=32768 Restart=always RestartSec=3 -# Make sure the run directory exists and is owned as expected. + +# Create the run directory ExecStartPre=-/bin/mkdir -p __RUNDIR__/__PROG__ -ExecStartPre=-/bin/chown __PSUSER__:__PSUSER__ __RUNDIR__/__PROG__ ExecStartPre=-/bin/chmod 755 __RUNDIR__/__PROG__ # Set up some temporary space and export its location ExecStartPre=-/bin/mkdir -p __RUNDIR__/__PROG__/tmp ExecStartPre=-/bin/chmod 700 __RUNDIR__/__PROG__/tmp -ExecStartPre=-/bin/chown __PSUSER__:__PSUSER__ __RUNDIR__/__PROG__/tmp Environment=TMPDIR=__RUNDIR__/__PROG__/tmp +# Set ownership +ExecStartPre=-/bin/chown -R __PSUSER__:__PSUSER__ __RUNDIR__/__PROG__ + + # Generate options file ExecStartPre=-/bin/sh -c "if [ -r __CONFIGDIR__/__PROG__.conf ]; then opts=$(sed -e 's/#.*$//' __CONFIGDIR__/__PROG__.conf); echo OPTIONS=$opts > __RUNDIR__/__PROG__/options; chown __PSUSER__:__PSUSER__ __RUNDIR__/__PROG__/options; fi" @@ -34,7 +36,7 @@ StandardError=journal # Start service EnvironmentFile=-__RUNDIR__/__PROG__/options -ExecStart=__DAEMONDIR__/__PROG__ --dsn @__DSN__ $OPTIONS --pid-file __RUNDIR__/__PROG__/pid +ExecStart=__DAEMONDIR__/__PROG__ --dsn @__DSN__ $OPTIONS # Stop service ExecStopPost=/bin/rm -rf __RUNDIR__/__PROG__ diff --git a/pscheduler-server/pscheduler-server/daemons/ticker b/pscheduler-server/pscheduler-server/daemons/ticker index 1948192f3..17cc19904 100755 --- a/pscheduler-server/pscheduler-server/daemons/ticker +++ b/pscheduler-server/pscheduler-server/daemons/ticker @@ -3,7 +3,6 @@ # Operate all on-boot and periodic functions in the database. # -import daemon import errno import optparse import pscheduler @@ -20,17 +19,6 @@ pscheduler.set_graceful_exit() opt_parser = optparse.OptionParser() -# Daemon-related options - -opt_parser.add_option("--daemon", - help="Daemonize", - action="store_true", - dest="daemon", default=False) -opt_parser.add_option("--pid-file", - help="Location of PID file", - action="store", type="string", dest="pidfile", - default=None) - # Program options opt_parser.add_option("-d", "--dsn", @@ -164,9 +152,4 @@ def main_program(): db.close() -with pscheduler.PidFile(options.pidfile) as pidfile: - if options.daemon: - with daemon.DaemonContext(pidfile=pidfile): - main_program() - else: - main_program() +main_program()