Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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

Installation

::
pip install simpledaemon

Example

Writing a daemon requires creating two files, a daemon file which simply enters an infinite loop and does whatever you want it to do, and a configuration file with the same name which tells simpledaemon how to setup your daemon.

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]
pidfile = ./hellodaemon.pid
logfile = ./hellodaemon.log
loglevel = info

Usage

To use your new daemon, execute your script like so:

./hello.py --start

Stopping is similar:

./hello.py --stop

For a full list of options, see the help:

./hello.py --help

Bugs

If you come across any bugs in simpledaemon. Kindly file an issue at: https://bitbucket.org/donspaulding/simpledaemon/issues/new

Pull requests are also welcome.

Release History

Release History

This version
History Node

1.3.0

History Node

1.0.1

History Node

1.0.0

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
SimpleDaemon-1.3.0.tar.gz (7.1 kB) Copy SHA256 Checksum SHA256 Source Feb 27, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting