25

I am attempting to use the python-daemon library which seemed to me to be the safest way to create a Daemon without forgetting anything. The documentation is quite poor, being just PEP 3143.

On the other hand, I have found a lot of links to Sander Marechal's A simple unix/linux daemon in Python. This looks to be a nicer solution or though I have not yet attempted to use it.

Edit: I have used Sander Marechal's solution and it seems to work nicely.


So what is the de facto way in the Python community to create a Daemon, is it one of these libraries, or simply doing it all yourself (forking twice etc.)?

Also, you would think that any library with a PEP would be a far better choice since it is closer to a comprehensive way of creating a Daemon (or at least a more standard way) than any other solution. So what is the deal with this python-daemon package, would it ever be included in the standard library?

Rusi
  • 1,054
  • 10
  • 21
Marcus Whybrow
  • 19,578
  • 9
  • 70
  • 90

3 Answers3

10

I went with Sander Marechal's A simple unix/linux daemon in Python, it is simple, and you work with it by creating a subclass and overriding the run() method, which feels a very natural way to do things (rather than the with context: approach of the python-daemon module.

Rusi
  • 1,054
  • 10
  • 21
Marcus Whybrow
  • 19,578
  • 9
  • 70
  • 90
  • Corrected the broken link. Also checked that the new link and the one on web-archive are the same modulo white-space differences. – Rusi Feb 12 '19 at 11:59
  • 1
    You could share implementation and and reference link separately. The reference link is broken... –  Oct 30 '20 at 02:06
  • @lapestand You'll have to forgive that I am no longer am knowledgeable enough to answer this question; owing to the fact of nine years passing. – Marcus Whybrow Oct 31 '20 at 04:13
1

For making a daemon program that will work correctly with the various runners in operating systems (e.g. init, systemd, launchd), the python-daemon library is the de facto way to write just the daemon part and let the operating system do the rest of the job correctly.

bignose
  • 30,281
  • 14
  • 77
  • 110
1

Twisted comes with twistd.

http://twistedmatrix.com/documents/current/core/howto/basics.html

You can wrap your application as a plugin for twistd.

Eddy Pronk
  • 6,527
  • 5
  • 33
  • 57