Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 78 lines (53 sloc) 2.116 kB
e1c23b4 @tj Initial commit
authored
1
2 # mon(1)
3
4 Super-simple monitoring program.
5
6 Effectively all it does is daemonize some programs,
7 re-executing the program on failure, write pidfiles,
8 and provide status checks.
9
10 ## Installation
11
12 ```
13 $ make install
14 ```
15
16 ## Usage
17
18 ```
19
73f2c3d @tj docs
authored
20 Usage: mon [options]
e1c23b4 @tj Initial commit
authored
21
22 Options:
23
73f2c3d @tj docs
authored
24 -V, --version output program version
25 -h, --help output help information
26 -l, --log <path> specify logfile [mon.log]
27 -s, --sleep <sec> sleep seconds before re-executing [1]
28 -S, --status check status of --pidfile
29 -p, --pidfile <path> write pid to <path>
30 -m, --mon-pidfile <path> write mon(1) pid to <path>
31 -P, --prefix <str> add a log prefix
32 -d, --daemonize daemonize the program
33 -e, --on-error <cmd> execute <cmd> on errors
e1c23b4 @tj Initial commit
authored
34
35 ```
36
37 ## Example
38
39 `mon(1)` is designed to monitor a single program only, this means a few things,
40 firstly that a single `mon(1)` may crash and it will not influence other programs,
41 secondly that the "configuration" for `mon(1)` is simply a shell script,
42 no need for funky weird inflexible DSLs.
43
44 ```bash
45 #!/usr/bin/env bash
46
47 pids="/var/run"
48 app="/www/example.com"
49
50 mon -d redis-server -p $pids/redis.pid
51 mon -d "node $app/app" -p $pids/app-0.pid
52 mon -d "node $app/jobs" -p $pids/jobs-0.pid
53 mon -d "node $app/jobs" -p $pids/jobs-1.pid
54 mon -d "node $app/jobs" -p $pids/jobs-2.pid
55 mon -d "node $app/image" -p $pids/image-0.pid
56 mon -d "node $app/image" -p $pids/image-1.pid
57 mon -d "node $app/image-broker" -p $pids/image-broker.pid
58 ```
512067b @tj docs
authored
59
60 ## Restarting processes
61
62 Restarting a process is simple, `kill(1)` it. For example if your app is written
63 to gracefully exit on __SIGQUIT__ you might want to do:
64
65 $ kill -s SIGQUIT $(cat /var/run/app-0.pid)
66
67 Or if you just want things done quick and dirty:
68
69 $ kill -s SIGKILL $(cat /var/run/app-0.pid)
25e700e @tj docs
authored
70
71 `mon(1)` will see that the child died, and re-execute
72 the initial start command.
6b1ae65 @tj Added --on-error <cmd>
authored
73
74 ## Links
75
76 Tools built with `mon(1)`:
77
2834819 @tj docs
authored
78 - [mongroup(1)](https://github.com/jgallen23/mongroup) - monitor a group of processes
Something went wrong with that request. Please try again.