As part of the Ubuntu Accomplishments system I have a daemon that runs as well as a client that connects to it. The daemon is written in Python (using Twisted) and provides a dbus service and a means of processing requests from the clients.
Right now the daemon is just a program I run before I run the client and it sets up the dbus service and provides an API that can be used by the clients.
I want to transform this into something that can be installed and run as a system service for the user's session (e.g. starting on boot) and providing a means to start and stop it etc.
The problem is, I am not sure what I need to do to properly daemonify it so it can run as this service. I wanted to ask if others can provide some guidance. Some things I need to ask:
- How can I treat it as a service that is run for the current user service (not a system service right now)?
- How do I ensure I can start, stop, and restart this session service?
- When packaging this, how do I ensure that it installs it as a service for the user's session and is started on login etc?
In responding, if you can point me to specific examples or solutions I need to implement, that would be helpful. :-)
Thanks!
I found several how-to's just by running a Google search:
http://www.enderunix.org/docs/eng/daemon.php
http://www.netzmafia.de/skripten/unix/linux-daemon-howto.html
http://code.activestate.com/recipes/66012-fork-a-daemon-process-on-unix/
http://cjh.polyplex.org/software/daemon.pdf
I hope they can help you on your way.
A daemon is basically a program with no direct user interaction... So there is nothing really specific about it. Nevertheless, you have to take care about some keys points :