Skip to main content

Library to enable your code run as a daemon process on Unix-like systems.

Project description

Latest version Travis CI

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

daemonize-2.4.1.tar.gz (8.4 kB view details)

Uploaded Source

File details

Details for the file daemonize-2.4.1.tar.gz.

File metadata

  • Download URL: daemonize-2.4.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for daemonize-2.4.1.tar.gz
Algorithm Hash digest
SHA256 2fbe8a4af6bafb3f53d64b8c05c073bfff6c8bc829b83563f5774b0052fc656e
MD5 f08ad971573a1d83d2d4adab13f59448
BLAKE2b-256 0b0c199bf3ab07e8924c3852076ac3c2ea918ca462f4e6f056029e67f571bcd3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page