Skip to main content

Python supervise

This module provide a methods to handle runit or daemontools based supervised services, using the control file provided. Here is a small example:

>>> import supervise
>>> s = supervise.Service('test')
>>> print s.status()
{'action': None, 'status': 0, 'uptime': 300L, 'pid': None}
>>> s.start()
>>> print s.status()
{'action': None, 'status': 1, 'uptime': 3L, 'pid': 27450}

Read the manpage of runsv(8) for more information. Also read the documentation for ServiceStatus to known how to parse status information.

History

Last month I needed to install runit in some servers to supervise a couple of services. Unfortunately my management interface cannot handle the services anymore, so I decided to write a small module in python to solve this handicap, and that is the result!.

With this module you can handle in python environment a number of runit scripts. I think that this might be work for daemontools too, but I do not test yet. Let’s see an example:

>>> import supervise
>>> c = supervise.Service("/var/service/httpd")
>>> print s.status()
{'action': 'normal', 'status': 'up', 'uptime': 300L, 'pid': None}
>>> if s.status()['status'] == supervise.STATUS_DOWN: print "service down"
service down
>>> s.start()
>>> if s.status()['status'] == supervise.STATUS_UP: print "service up"
service up

Personally I use this module with rpyc library to manage remotely the services running in a host, but it too easy making a web interface, for example using bottle:

import supervise
import simplejson
from bottle import route, run

@route('/service/status/:name')
def service_status(name):
    return simplejson.dumps( supervise.Service("/var/service/" +
        name).status() )

@route('/service/up/:name')
def service_up(name):
    c = supervise.Service("/var/service/" + name)
        c.start()
    return "OK UP"


@route('/service/down/:name')
def service_down(name):
    c = supervise.Service("/var/service/" + name)
        c.down()
    return "OK DOWN"


if __name__ == "__main__":
    run()

Now you can stop your service just only point your browser http://localhost/service/down/httpd (to down http service in this case).

Enjoy!

author:

Andres J. Diaz <ajdiaz@connectical.com>

date:

2009-11-21

maintainer:

Peter Ruibal <ruibalp@gmail.com>

Metadata

Release files for supervise 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for supervise 1.1.1
File Size Uploaded Provenance
supervise-1.1.1.tar.gz 5.0 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for supervise 1.1.1
File Interpreter ABI Platform
supervise-1.1.1-py2.7.egg Legacy Egg format - - Details
supervise-1.1.1-py2.6.egg Legacy Egg format - - Details

Total release size: 25.2 kB

Release files / supervise-1.1.1.tar.gz

Download URL supervise-1.1.1.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8671e1fedf064c24190d468be8248433032917167605f585b4c2c55a27be4132
BLAKE2b-256 checksum
How to use checksums
f68de4d2f8e975fa5364f217fce875420beac2de45c22b2c4ac0c6c64355d5e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / supervise-1.1.1-py2.7.egg

Download URL supervise-1.1.1-py2.7.egg
Size 10.1 kB
Tags Egg
SHA-256 checksum
How to use checksums
dc24e08bac183255405ced40106d2e25fc2777b8256b5d6ae1c9fd55187f3053
BLAKE2b-256 checksum
How to use checksums
b8868800653f7ea85e3ab38be4f4a556b11f1b12ff8fd445fd265f6b75cb9408
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / supervise-1.1.1-py2.6.egg

Download URL supervise-1.1.1-py2.6.egg
Size 10.1 kB
Tags Egg
SHA-256 checksum
How to use checksums
949aab2e508a709c9b5347a57ba7fd9cba586e1b6125d232340d9a17846415fb
BLAKE2b-256 checksum
How to use checksums
448d4884b5d5263ad999597c00516f417a5e72fa686ff99a2c79e25b7f41394b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for supervise 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page