# README
Procmon
Procmon is a process runner/monitor tool that can start and stop a set of tasks and rerun them if they fail.
What's unique about it compared to things like supervisor is that it lets you define a dependency tree of processes, so that when a parent process dies, its children can be terminated and re-run after the parent has started again.
It's designed to work when run inside a container.
Features
- Watches long-running tasks to see if they terminate
- Kills off children if the parent terminates, then restarts in order
- Flexible idea of additional "behavioral" monitors that can monitor a variety of things (http health, RPC, etc).
- A monitor reports failure as if the task has died
- Signal management; shuts everything down on exit
- Kill off tasks that fail monitoring but are still running
- Timeouts to force restart if things don't shut down when requested
- Composable monitors allow making them more sophisticated when desired
- Redirection of stdout/stderr
- Logging its own behavior to log files or to honeycomb
- Use SIGHUP to trigger a special task after shutting down everything (for example, for backup)
- A task definition language (config) so we don't need to compile the tool when tasks change
Task definition language
The tasks are defined in a TOML file; see sample.toml for an example.
# Functions
BuildMonitor constructs a monitor from an element in the Monitors map.
EnsureDir ensures that a given path name exists as a directory on the filesystem; if it already exists, nothing happens, but if it doesn't exist, it tries to create it with the given permissions.
HTTPPinger returns a function compatible with the Monitor's Test parameter that pings an HTTP address with a timeout.
Load does the toml load into a config object.
NewErrorEvent constructs an ErrorEvent.
NewFailMonitor creates a FailMonitor from a Monitor.
NewMonitor returns a new monitor object.
NewRetryMonitor wraps an existing monitor with retry logic.
NewTask creates a Task (but does not start it) The default Ready() function simply returns true.
NewTasks creates the Tasks object.
PortAvailable returns an Eventer that tests to see if a given port on the local machine is available to be claimed by a process.
PortInUse returns an Eventer that tests to see if a given port on the local machine is being serviced by a process.
RedisPinger returns a function that sends a Ping to the redis service at the given address and expects PONG.
WatchSignals can set up functions to call on various operating system signals.
# Constants
These constants are used to indicate possible event types.
These constants are used to indicate possible event types.
LoggerOutput string constants.
LoggerOutput string constants.
LoggerOutput string constants.
These constants are used to indicate possible event types.
These constants are used to indicate possible event types.
# Structs
Config is the overall structure for a procmon TOML config file It looks like sample.toml.
The ConfigTask section is a map ("table") of tasks.
ErrorEvent is an Event that can carry an error as well.
FailMonitor wraps a monitor and only sends Failure events; it sends one when it receives one from its wrapped monitor.
Monitor defines a listener that is calling a Test function periodically.
RetryMonitor wraps a monitor and will only fail after receiving a number of successive failures that exceeds the Retries value.
Task is a restartable process; it can be monitored and restarted.
Tasks is the container for all the task types that get manipulated.
# Type aliases
Event is the type that indicates the status of a Task.