simple library to make service on python more easy
Python Graphviz (DOT)
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
examples
tests
.gitignore
LICENSE
Makefile
NOTICE
README.md
pyservice.py
setup.cfg
setup.py

README.md

pyservice

Introduction

simple library to make service on python more easy. That's experimental project. Ideas were taken from progrium/ginkgo, daemon.py for python 2.x and daemon.py for python 3.x.

The pyservice is responsible for creating a "container" to run services in, and tools to manage that container. The container is itself a service based on a class called Process, which is intended to model the running process that contains the service. The pyservice initializes the process to daemonize then the process takes an application service to run.

Installation

To install pyservice just download pyservice.py and place it in your project directory. There are no dependencies other than the Python Standard Library.

How to start to use

The example of simple process

import os
import time
import pyservice

class SimpleProcess(pyservice.Process):

    pidfile = os.path.join(os.getcwd(), 'tests/run/simple_process.pid')
    logfile = os.path.join(os.getcwd(), 'tests/log/simple_process.log')

    def run(self):
        time.sleep(10)

To run this process as service you just need to type in command line

$ python -m pyservice tests.processes.simple_process.SimpleProcess start

Details

The "ControlInterface" class models the commands you can use to start or control a daemonized service. This is exposed via one command line utilities "pyservice" which have the entry point defined in this module.

The runner module and command line utilities are completely optional. You can always just write your own Python script or console command that takes your application service.

Examples

Where does it used?

  • pywebase Small platform for local web applications
  • pyactors Simple implementation actors on python

Links

For developers

For testing purpose nose and coverage libraries are required

$ pip install nose
$ pip install coverage