cronmon

command module
v0.0.0-...-d3b71cc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2021 License: LGPL-3.0 Imports: 13 Imported by: 0

README

cronmon

A lightweight service manager that monitors itself using crond. Designed to be used where a service manager is not available.

Differences vs. Other Monitors

  • Cron-based.
  • Simple service file syntax (there's none).
  • Easily statically compiled (CGO_ENABLED=0 go build).

For a detailed explanation of how cronmon works exactly, see its documentation.

Compatibility

Cronmon uses two features that makes it only work on Linux: (syscall.SysProcAttr).Pdeathsig and PR_SET_CHILD_SUBREAPER. The usage of these two features are documented in the above documentation.

Installation

  1. Install cronmon: go install git.unix.lgbt/diamondburned/cronmon.
  2. Edit crontab: crontab -e.
  3. Add cronmon into the cron file.
Cron File

A cron file can be generated by running cronmon cron. Below is a simple example:

# Start cronmon immediately on startup.
@reboot /tmp/cronmon
# Monitor cronmon's status every minute.
* * * * * /tmp/cronmon

This cron file will launch cronmon with the journal file pointing to ~/.config/cronmon/journal.json and the scripts (service) directory pointing to ~/.config/cronmon/scripts/.

Service File Example

$ # Shell script example.
$ cat <<'EOF' > ~/.cronmon/scripts/sysmetd.sh
#!/bin/sh
exec sysmet -flag "$shell_env" -listen unix:///tmp/a.sock
EOF
$ chmod +x ~/.cronmon/scripts/sysmetd.sh
$
$ # Executable example.
$ wget -O ~/.cronmon/scripts/example https://dodgy.site/executable
$ chmod +x ~/.cronmon/scripts/example

New service files will automatically be executed, and old service files that are updated will automatically restart the process. Removing a service file will stop the process. Removing the executable bit from a file (chmod -x) makes cronmon stop the process as well. Adding back the bit (chmod +x) makes it start the process again.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package cronmon is the core of the cronmon application, providing individual components that work independently, while communicating with eachother concurrently over channels.
Package cronmon is the core of the cronmon application, providing individual components that work independently, while communicating with eachother concurrently over channels.
exec
Package exec provides an abstraction around package os' Process implementation for easier testing.
Package exec provides an abstraction around package os' Process implementation for easier testing.
journal
Package journal provides an implementation of cromon's Journaler interface to write to a file.
Package journal provides an implementation of cromon's Journaler interface to write to a file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL