Skip to main content

A package to run and monitor background services

Project description

uMonitor

This is a minimalistic python supervisor for your microservices.
Once started, it will launch all the services you've specified in the provided config file, and monitor their execution. Suppose you have following services in the config.json:

{
    "services" : [
        {
            "comment": "Another service to run and monitor.",
            "program" : "python3",
            "args" : ["other_script.py"],
            "persist"  : true,
            "cwd" : "/opt"
        },
        {
            "comment": "And this one should not be restarted",
            "program" : "bash",
            "args" : ["will_be_executed_with_bin_bash.sh"],
            "persist" : false,
            "cwd" : "/opt"
        }
    ]
}

Then the supervisor (uMonitor) will run the specified commands and for those which have persis set, will restart the described processes, whenever they fail/crash.

More complex: it also provides environment variables and venv-like behavior for the specified programs. See the config_example.json for more details.

{
    "comment": "Treat this as virtual environment, but not only for python.",
    "interpreters" : {
        "python3" : "/venv_some/bin/python3",
        "sh" : "/bin/sh",
        "bash" : "/bin/bash"
    },

    "comment": "Services to run and monitor.",
    "services" : [
        {
            "program" : "python3",
            "args" : ["script_1.py"],
            "comment": "Do not recover after crashes",
            "persist" : false,
            "cwd" : "/opt",
            "env" : {
                "PYTHONPATH" : [
                    "/opt/your_python_module/",
                    "/usr/local/another/module/",
                    "/joined_with/colon/will_be"
                ],
                "PATH": [
                    "/opt/prog_1/bin/",
                    "/home/username/.prog_2/bin/",
                    "/joined_with/colon/will_be"
                ],
                "ENVIRON_VARIABLE": [
                    "SINGLE_VALUE_42"
                ]
            }
        },
        {
            "comment": "Another service to run and monitor.",
            "program" : "python3",
            "args" : ["other_script.py"],
            "persist"  : true,
            "cwd" : "/opt"
        },
        {
            "comment": "And this one should not be restarted",
            "program" : "bash",
            "args" : ["will_be_executed_with_bin_bash.sh"],
            "persist" : false,
            "cwd" : "/opt"
        }
    ]
}

Installation:

  • Installation using pip:
python3 -m pip install umonitor
  • Installation using poetry:
poetry add umonitor

Usage example:

  • As a callable module:
python3 -m umonitor config.json
  • In a script:
import umonitor

monitor = umonitor.uMonitor("config.json")
monitor.run()

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

uMonitor-0.1.5.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

uMonitor-0.1.5-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file uMonitor-0.1.5.tar.gz.

File metadata

  • Download URL: uMonitor-0.1.5.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.7.12 Linux/5.4.0-87-generic

File hashes

Hashes for uMonitor-0.1.5.tar.gz
Algorithm Hash digest
SHA256 4de05cd1b774fa11afbec2a275deb7ad16ae9cf79a7e97bc4aefd7482212cf47
MD5 1b6929cc1e07c2f73c901b528f8c2a72
BLAKE2b-256 b0d0ca90eddaefa7f82420f5981b20008696f1e475b13141e4b84a01301c1ab6

See more details on using hashes here.

File details

Details for the file uMonitor-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: uMonitor-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.7.12 Linux/5.4.0-87-generic

File hashes

Hashes for uMonitor-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5916e2430180bd9eceb5a6103102b4f6f3a99e0bccf6c3bb1f22eae450f4d2c1
MD5 b9f8263d94510187bc2be771219bd963
BLAKE2b-256 3e07f3f3962ad62dbeb609cd18cf47795312ebb06ad4687fecb74f739d932d08

See more details on using hashes here.

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