Skip to main content

Provides a simple Daemon class to ease the process of forking a python application on Unix systems.

Project description

A fork of Shane Hathaway’s daemon.py script.

Features

  • reads the command line

  • reads a configuration file

  • configures logging

  • calls root-level setup code

  • drops privileges

  • calls user-level setup code

  • detaches from the controlling terminal

  • checks and writes a pidfile

Example

Writing a daemon requires creating two files, a daemon file and a configuration file with the same name.

hellodaemon.py:

import simpledaemon
import logging
import time

class HelloDaemon(simpledaemon.Daemon):
    default_conf = '/etc/hellodaemon.conf'
    section = 'hello'

    def run(self):
        while True:
            logging.info('The daemon says hello')
            time.sleep(1)

if __name__ == '__main__':
    HelloDaemon().main()

hellodaemon.conf:

[hello]
uid =
gid =
pidfile = ./hellodaemon.pid
logfile = ./hellodaemon.log
loglevel = info

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

SimpleDaemon-1.0.1.tar.gz (5.5 kB view hashes)

Uploaded Source

Supported by

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