Skip to main content

Watchmen is a daemon process manager that for you manage and keep your application online 24/7

Project description

Watchmen (0.0.1)

Watchmen is a daemon process manager that for you manage and keep your application online 24/7

中文简体 | English

Install

Build from source

# Clone the repository
git clone https://git.ahriknow.com/ahriknow/watchmenpy.git

# Go into the repository
cd watchmenpy

# Install watchmen daemon and cli tool
pip install -e .

Install from pypi

# Install watchmen daemon
pip install watchmen

Getting Started

Generate config file

"" Default is ${HOME}/.watchmen/config.toml

watchmen -g ""

[watchmen]
# The engine to use for the watchmen server
# Valid values are "sock", "socket", "http", "redis"
# sock: Unix socket
# socket: TCP socket
# http: HTTP Api (Include Web panel)
# redis: Redis pub/sub
engines = ["sock"]

# The default engine to use for connecting to the watchmen server
engine = "sock"

# The log directory of the watchmen server
log_dir = "$HOME/.watchmen/logs"

# The log level of the watchmen server
# Valid values are "debug", "info", "warn", "error". Default is "info"
log_level = "info"

# The standard output of the watchmen server
# Default is None
stdout = "$HOME/.watchmen/watchmen.stdout.log"

# The standard error of the watchmen server
# Default is None
stderr = "$HOME/.watchmen/watchmen.stderr.log"

# The pid file of the watchmen server
# Default is `$HOME/.watchmen/watchmen.pid`
pid = "$HOME/.watchmen/watchmen.pid"

# The task config file name matching pattern
# Default is `^.*\\.(toml|ini|json)$`
mat = "^.*\\.(toml|ini|json)$"

# Tasks cache file, json format
cache = "$HOME/.watchmen/cache.json"

# Monitor interval for rerun tasks, u64: second
interval = 5


[sock]
# The unix socket path of the watchmen server
path = "/tmp/watchmen.sock"


[socket]
host = "127.0.0.1"
port = 1949


[http]
host = "127.0.0.1"
port = 1997


[redis]
host = "localhost"
port = 6379
username = ""
password = ""
queue_index = 0
queue_name = "watchmen"
subscribe_channels = ["watchmen"]
subscribe_name = "watchmen"

Start watchmen daemon

watchmend

Task Config file

[[task]]
id = 1
name = "Async Task 1"
command = "command"
args = ["arg1", "arg2"]
dir = "/path/to/directory"
env = { key1 = "value1", key2 = "value2" }
stdin = true
stdout = "output.txt"
stderr = "error.txt"
task_type = { Async = { max_restart = 2, has_restart = 0, started_at = 0, stopped_at = 0 } }
[Async Task]
id = 2
name = Async Task 2
command = command
args = arg1 arg2
dir = /path/to/directory
env = key1=value1 key2=value2
stdin = true
stdout = "output.txt"
stderr = "error.txt"
task_type = async
max_restart = 2
[
    {
        "id": 3,
        "name": "Async Task 3",
        "command": "command",
        "args": ["arg1", "arg2"],
        "dir": "/path/to/directory",
        "env": {},
        "stdin": true,
        "stdout": "output.txt",
        "stderr": "error.txt",
        "created_at": 0,
        "task_type": { "Async": { "max_restart": 2, "has_restart": 0, "started_at": 0, "stopped_at": 0 } }
    }
]

Command

watchmen -h

usage: watchmen [OPTIONS] [COMMAND]

Watchmen (Python) is a daemon process manager that for you manage and keep your application online 24/7

options:
  -h, --help            show this help message and exit
  -c <CONFIG>, --config <CONFIG>
                        Config file path. Default: $HOME/.watchmen/config.toml
  -g <GENERATE>, --generate <GENERATE>
                        Generate config file
  -e <ENGINE>, --engine <ENGINE>
                        Engine for send message
  -v, --version         Print version

Sub Commands:
  {run,add,reload,start,restart,stop,remove,pause,resume,list}
    run                 Add and run tasks
    add                 Add tasks
    reload              Reload tasks
    start               Start tasks
    restart             Restart tasks
    stop                Stop tasks
    remove              Remove tasks
    pause               Pause tasks
    resume              Resume tasks
    list                Get tasks list

See "watchmen COMMAND --help" for more information on a specific command.

watchmen run -h

usage: watchmen run [OPTIONS]

options:
  -h, --help            show this help message and exit
  -p <PATH>, --path <PATH>
                        Task config directory
  -r <REGEX>, --regex <REGEX>
                        Task config filename regex pattern
  -f <CONFIG>, --config <CONFIG>
                        Task config file
  -n <NAME>, --name <NAME>
                        Task name (unique)
  -c <COMMAND>, --command <COMMAND>
                        Task command
  -a <ARGS> [<ARGS> ...], --args <ARGS> [<ARGS> ...]
                        Task arguments
  -d <DIR>, --dir <DIR>
                        Task working directory
  -e <ENV> [<ENV> ...], --env <ENV> [<ENV> ...]
                        Task environment variables
  -i, --stdin           Task standard input
  -o <STDOUT>, --stdout <STDOUT>
                        Task standard output
  -w <STDERR>, --stderr <STDERR>
                        Task standard error

watchmen add -h

usage: watchmen add [OPTIONS]

options:
  -h, --help            show this help message and exit
  -p <PATH>, --path <PATH>
                        Task config directory
  -r <REGEX>, --regex <REGEX>
                        Task config filename regex pattern
  -f <CONFIG>, --config <CONFIG>
                        Task config file
  -n <NAME>, --name <NAME>
                        Task name (unique)
  -c <COMMAND>, --command <COMMAND>
                        Task command
  -a <ARGS> [<ARGS> ...], --args <ARGS> [<ARGS> ...]
                        Task arguments
  -d <DIR>, --dir <DIR>
                        Task working directory
  -e <ENV> [<ENV> ...], --env <ENV> [<ENV> ...]
                        Task environment variables
  -i, --stdin           Task standard input
  -o <STDOUT>, --stdout <STDOUT>
                        Task standard output
  -w <STDERR>, --stderr <STDERR>
                        Task standard error

watchmen reload -h

usage: watchmen reload [OPTIONS]

options:
  -h, --help            show this help message and exit
  -p <PATH>, --path <PATH>
                        Task config directory
  -r <REGEX>, --regex <REGEX>
                        Task config filename regex pattern
  -f <CONFIG>, --config <CONFIG>
                        Task config file
  -n <NAME>, --name <NAME>
                        Task name (unique)
  -c <COMMAND>, --command <COMMAND>
                        Task command
  -a <ARGS> [<ARGS> ...], --args <ARGS> [<ARGS> ...]
                        Task arguments
  -d <DIR>, --dir <DIR>
                        Task working directory
  -e <ENV> [<ENV> ...], --env <ENV> [<ENV> ...]
                        Task environment variables
  -i, --stdin           Task standard input
  -o <STDOUT>, --stdout <STDOUT>
                        Task standard output
  -w <STDERR>, --stderr <STDERR>
                        Task standard error

watchmen start -h

usage: watchmen start [OPTIONS]

options:
  -h, --help            show this help message and exit
  -p <PATH>, --path <PATH>
                        Task config directory
  -r <REGEX>, --regex <REGEX>
                        Task config filename regex pattern
  -f <CONFIG>, --config <CONFIG>
                        Task config file
  -i <ID>, --id <ID>    Task id (unique)
  -n <NAME>, --name <NAME>
                        Task name (unique)
  -m, --mat             Is match regex pattern by namae

watchmen restart -h

usage: watchmen restart [OPTIONS]

options:
  -h, --help            show this help message and exit
  -p <PATH>, --path <PATH>
                        Task config directory
  -r <REGEX>, --regex <REGEX>
                        Task config filename regex pattern
  -f <CONFIG>, --config <CONFIG>
                        Task config file
  -i <ID>, --id <ID>    Task id (unique)
  -n <NAME>, --name <NAME>
                        Task name (unique)
  -m, --mat             Is match regex pattern by namae

watchmen stop -h

usage: watchmen stop [OPTIONS]

options:
  -h, --help            show this help message and exit
  -p <PATH>, --path <PATH>
                        Task config directory
  -r <REGEX>, --regex <REGEX>
                        Task config filename regex pattern
  -f <CONFIG>, --config <CONFIG>
                        Task config file
  -i <ID>, --id <ID>    Task id (unique)
  -n <NAME>, --name <NAME>
                        Task name (unique)
  -m, --mat             Is match regex pattern by namae

watchmen remove -h

usage: watchmen remove [OPTIONS]

options:
  -h, --help            show this help message and exit
  -p <PATH>, --path <PATH>
                        Task config directory
  -r <REGEX>, --regex <REGEX>
                        Task config filename regex pattern
  -f <CONFIG>, --config <CONFIG>
                        Task config file
  -i <ID>, --id <ID>    Task id (unique)
  -n <NAME>, --name <NAME>
                        Task name (unique)
  -m, --mat             Is match regex pattern by namae

watchmen pause -h

usage: watchmen pause [OPTIONS]

options:
  -h, --help            show this help message and exit
  -p <PATH>, --path <PATH>
                        Task config directory
  -r <REGEX>, --regex <REGEX>
                        Task config filename regex pattern
  -f <CONFIG>, --config <CONFIG>
                        Task config file
  -i <ID>, --id <ID>    Task id (unique)
  -n <NAME>, --name <NAME>
                        Task name (unique)
  -m, --mat             Is match regex pattern by namae

watchmen resume -h

usage: watchmen resume [OPTIONS]

options:
  -h, --help            show this help message and exit
  -p <PATH>, --path <PATH>
                        Task config directory
  -r <REGEX>, --regex <REGEX>
                        Task config filename regex pattern
  -f <CONFIG>, --config <CONFIG>
                        Task config file
  -i <ID>, --id <ID>    Task id (unique)
  -n <NAME>, --name <NAME>
                        Task name (unique)
  -m, --mat             Is match regex pattern by namae

watchmen list -h

usage: watchmen list [OPTIONS]

options:
  -h, --help            show this help message and exit
  -p <PATH>, --path <PATH>
                        Task config directory
  -r <REGEX>, --regex <REGEX>
                        Task config filename regex pattern
  -f <CONFIG>, --config <CONFIG>
                        Task config file
  -i <ID>, --id <ID>    Task id (unique)
  -n <NAME>, --name <NAME>
                        Task name (unique)
  -R, --mat             Is match regex pattern by name
  -m, --more            Show more info
  -l, --less            Show less info

License Apache Licence 2.0

License

Copyright ahriknow 2022

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

watchmenpy-0.0.1.tar.gz (25.0 kB view details)

Uploaded Source

Built Distribution

watchmenpy-0.0.1-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file watchmenpy-0.0.1.tar.gz.

File metadata

  • Download URL: watchmenpy-0.0.1.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for watchmenpy-0.0.1.tar.gz
Algorithm Hash digest
SHA256 2089223284c6e3fb03c6bb184b0eb68416f65f2573cb79bb04480407c2fb0499
MD5 55f50568d328ac04291f6ea69eb3e72d
BLAKE2b-256 8aa27b55a3867fe5ed2891bcba868a1a2af2b50ba7f389892196b0e9c6a265d4

See more details on using hashes here.

File details

Details for the file watchmenpy-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: watchmenpy-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 33.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for watchmenpy-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a8050d8d26db37e7785a76697cde58eae6eada62868ce37b4ad6833ba3459f39
MD5 96b91ef0dab8e093d0833ebd44dcfd1b
BLAKE2b-256 0cb33d737235681ca410c6fdd1ed2633b2d871230d203d791d8f54cf40fc2cbf

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