Daemon Creation



Hello Guys,

I’ve got a python script which I’m looking to launch as a Daemon on my system. There are a few things which need to be handled on the python side of things to get this to work, but I can deal with these myself without any issues.

Where I DO need help though is with regards to writing the Daemon file for init.d which can then be used to launch and stop the Daemon. I hound an excellent little tutorial based here: http://girasoli.org/?p=120 which has helped me get started by creating a copy of the skeleton Daemon and start to customize it, however, it seems a little out of date and I need a little help with this.

Within the Daemon control script we have do_start() and do_stop() methods. I need to know if these really need to be modified as stated in the tutorial? At the moment my start script looks like this:

do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ $DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}

Is that correct? Presumably I need to remove one of those start commands? Right? The same rule applied to the do_stop() method which currently contains a start-stop-daemon request, do I need to replace that with a standard kill command? Or will the start-stop-daemon handle that for me?

Thanks for any input you can offer guys, I appreciate it.

Robert
_________________________________________________________________
Get Hotmail on your mobile, text MSN to 63463!
http://mobile.uk.msn.com/pc/mail.aspx

Relevant Pages

  • Re: Confused about init scripts expectations
    ... I am developing a daemon application to handle datalogger ... I have developed the init script that is ... I attempt to start the daemon using the services configuration GUI ... figure is that the EOF signal is not being received by the program. ...
    (Fedora)
  • Re: [opensuse] BASH: has $COLUMNS gone nuts?
    ... You do realize that lines & columns are dynamic values which at least some terminals and login daemons will continuously adjust right? ... What the above shows is that I dragged the corner of my PuTTY window (which was connected to sshd, not every terminal client nor every server daemon does this) making the window a little larger and without issuing any commands, and no possibility that any bashrc or inclusions got executed, the values changed, because the terminal told the daemon and the daemon told it's child processes. ... Try calling them from within a script: ... Although, I would also actually be perverse and say that since the SCO systems predate most others, including ALL linux, that you could actually make the argument that the dwindling remaining production sco boxes in the world are right and the 90 million linux & freebsd & sun boxes are all wrong. ...
    (SuSE)
  • [HPADM] Re: Startup Script Question
    ... Subject: Startup Script Question ... I have the following line for the start option to launch ... > boot, the startup script launches the daemon, but then the ...
    (HP-UX-Admin)
  • Re: script "chaining"
    ... If a task (such as a report) would take too long to run while attached to the browser, the current system writes the data to a database file. ... The daemon checks that file every 10 seconds and executes the task, writing the data back to database. ... If you take the A out of LAMP you can write a php script like a bash script or a perl script and execute it. ...
    (comp.lang.php)
  • Debian PHP jabber client deamon
    ... to prevent PHP stopping the script. ... // disconnect from the Jabber server ... Here's the daemon script for running it in Debian. ... # Gracefully exit if the package has been removed. ...
    (comp.lang.php)