How do I daemonify my daemon?

Posted by jonobacon on Ask Ubuntu See other posts from Ask Ubuntu or by jonobacon
Published on 2012-02-24T22:37:07Z Indexed on 2012/06/24 3:24 UTC
Read the original article Hit count: 198

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!

Jono

© Ask Ubuntu or respective owner

Related posts about python

Related posts about application-development