how can I run rails server daemon?
It should be: rails server –daemon # to kill the server kill `cat tmp/pids/server.pid` # to tail development logs for debugging tail -f log/development.log
It should be: rails server –daemon # to kill the server kill `cat tmp/pids/server.pid` # to tail development logs for debugging tail -f log/development.log
After spending a couple of hours of snooping around I ended up creating /etc/init.d/jboss with the following contents #!/bin/sh ### BEGIN INIT INFO # Provides: jboss # Required-Start: $local_fs $remote_fs $network $syslog # Required-Stop: $local_fs $remote_fs $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/Stop JBoss AS v7.0.0 … Read more
It is a program to manage the start and stop of system level background processes (daemons). You use it by passing in parameters (such as the pid file to create/check) and command arguments for the process you want to launch. Then, you do one of two things: start-stop-daemon -S [other arguments] something start something, if … Read more
To expand on ypocat’s answer, since it won’t let me comment: start-stop-daemon –start –quiet –chuid $DAEMONUSER \ –make-pidfile –pidfile $PIDFILE –background \ –startas /bin/bash — -c “exec $DAEMON $DAEMON_ARGS > /var/log/some.log 2>&1” Using exec to run the daemon allows stop to correctly stop the child process instead of just the bash parent. Using –startas instead … Read more
A class based clean to use solution: import signal import time class GracefulKiller: kill_now = False def __init__(self): signal.signal(signal.SIGINT, self.exit_gracefully) signal.signal(signal.SIGTERM, self.exit_gracefully) def exit_gracefully(self, *args): self.kill_now = True if __name__ == ‘__main__’: killer = GracefulKiller() while not killer.kill_now: time.sleep(1) print(“doing something in a loop …”) print(“End of the program. I was killed gracefully :)”)