RETIRED, further work has moved to Debian project infrastructure
Go to file
Ilya Otyutskiy 9018be18f9 Update Makefile 2016-07-28 23:06:00 +03:00
docs Remove api docs from readme 2015-11-02 18:16:26 +03:00
tests Update daemon_uid_gid_action.py 2015-12-13 19:35:24 +03:00
.gitignore Add sphinx-doc, migrate to rst in readme 2015-11-02 18:03:12 +03:00
.travis.yml Add "docs" target to Makefile. 2015-12-20 22:14:25 +03:00
LICENSE Document verbose parameter, update LICENSE. 2014-03-15 01:34:58 +04:00
MANIFEST.in Add sphinx-doc, migrate to rst in readme 2015-11-02 18:03:12 +03:00
Makefile Update Makefile 2016-07-28 23:06:00 +03:00
README.rst A little bit more verbose README.rst. 2015-12-03 15:54:39 +03:00
daemonize.py daemonize 2.4.7 2016-07-28 19:15:53 +03:00
setup.cfg Let's also build .whl now. 2015-12-13 18:53:42 +03:00
setup.py Confirm NetBSD support 2016-03-19 01:13:17 +03:00

README.rst

daemonize

Latest version

Travis CI

PyPI montly downloads

PyPI last version available

PyPI license

daemonize is a library for writing system daemons in Python. It is distributed under MIT license. Latest version can be downloaded from PyPI. Full documentation can be found at ReadTheDocs.

Dependencies

It is tested under following Python versions:

  • 2.6
  • 2.7
  • 3.3
  • 3.4
  • 3.5

Installation

You can install it from Python Package Index (PyPI):

$ pip install daemonize

Usage

from time import sleep
from daemonize import Daemonize

pid = "/tmp/test.pid"


def main():
    while True:
        sleep(5)

daemon = Daemonize(app="test_app", pid=pid, action=main)
daemon.start()

File descriptors

Daemonize object's constructor understands the optional argument keep_fds which contains a list of FDs which should not be closed. For example:

import logging
from daemonize import Daemonize

pid = "/tmp/test.pid"
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.propagate = False
fh = logging.FileHandler("/tmp/test.log", "w")
fh.setLevel(logging.DEBUG)
logger.addHandler(fh)
keep_fds = [fh.stream.fileno()]


def main():
    logger.debug("Test")

daemon = Daemonize(app="test_app", pid=pid, action=main, keep_fds=keep_fds)
daemon.start()