Code Monkey home page Code Monkey logo

yapdi's Introduction

YapDi - Yet another python Daemon implementation

Overview

As the name implies YapDi is yet another python daemon implementation. Python 2.x standard library didn't have a daemonizing module. It is one of those rare few modules python standard library lacked that put the phrase "batteries included" to shame. There is PEP 3143 which introduces a daemonizing package to python 3.x standard library.

Python community is scattered with so many daemon implementations and this is one of them. This module is a modified version of a code originally posted here. So any compliments should go there first.

Installation

python setup.py install

Basic Usage

import yapdi

# Creating a yapdi daemon instance
daemon = yapdi.Daemon()

# You can also supply a pid file name at daemon instance creation time
daemon = yapdi.Daemon(pidfile='/var/run/.myservice.pid')

# Daemonizing an instance; Any code placed under this would get executed in daemon mode
daemon.daemonize()

# Stopping a running instance
daemon.kill()

# Restarting an instance; If an instance is already running it would be killed and started again, else would just start
daemon.restart()

# Checking whether an instance is running
if daemon.status():
    print('An instance is already running')
else:
    print('No instance is running')

# Running a daemonized instance as a different user; any code below these two lines would get executed in daemon mode as user 'user123'
daemon.set_user('user123')
daemon.daemonize()

yapdi's People

Contributors

kasun avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.