RETIRED, further work has moved to Debian project infrastructure
Go to file
Ilya Otyutskiy 079827ccfc Document verbose parameter, update LICENSE. 2014-03-15 01:34:58 +04:00
tests Fix uid/gid tests on debian boxes. 2014-03-14 17:24:49 +04:00
.gitignore Added distutils generated directories into ignore. 2014-03-12 18:28:53 +01:00
.travis.yml Test Travis-CI webhooks. 2014-03-14 22:41:08 +04:00
LICENSE Document verbose parameter, update LICENSE. 2014-03-15 01:34:58 +04:00
MANIFEST.in Fix README and add LICENSE to MANIFEST.in. 2012-09-01 01:25:38 +04:00
README.md Nice syntax highlighting in README.md 2014-03-10 18:07:58 +03:00
daemonize.py Document verbose parameter, update LICENSE. 2014-03-15 01:34:58 +04:00
setup.py Added verbosity option in Daemonize class. 2014-03-12 18:28:00 +01:00

README.md

daemonize Build Status

Description

daemonize is a library for writing system daemons in Python. It has some bits from daemonize.sourceforge.net. It is distributed under MIT license.

Dependencies

It is tested under following Python versions:

  • 2.6
  • 2.7
  • 3.3

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()