Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Apr 12, 2012
0 parents commit e1c23b4
Show file tree
Hide file tree
Showing 6 changed files with 444 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.o
mon.log
mon
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

PREFIX = /usr/local
SRC = src/mon.c
OBJ = $(SRC:.c=.o)
CFLAGS = -D_GNU_SOURCE -std=c99

mon: $(OBJ)
$(CC) $^ -o $@

%.o: %.c
$(CC) $< $(CFLAGS) -c -o $@

install: mon
cp -f mon $(PREFIX)/bin/mon

uninstall:
rm -f $(PREFIX)/bin/mon

clean:
rm -f mon $(OBJ)

.PHONY: clean install uninstall
56 changes: 56 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

# mon(1)

Super-simple monitoring program.

Effectively all it does is daemonize some programs,
re-executing the program on failure, write pidfiles,
and provide status checks.

## Installation

```
$ make install
```

## Usage

```
Usage: mon [options] <cmd>
Options:
-s, --sleep <sec> sleep seconds before re-executing [1]
-S, --status check status of --pidfile
-l, --log <file> specify logfile [mon.log]
-d, --daemonize daemonize the program
-p, --pidfile <path> write pid to <path>
-P, --prefix <str> add a log prefix <str>
-v, --version output program version
-h, --help output help information
```

## Example

`mon(1)` is designed to monitor a single program only, this means a few things,
firstly that a single `mon(1)` may crash and it will not influence other programs,
secondly that the "configuration" for `mon(1)` is simply a shell script,
no need for funky weird inflexible DSLs.

```bash
#!/usr/bin/env bash

pids="/var/run"
app="/www/example.com"

mon -d redis-server -p $pids/redis.pid
mon -d "node $app/app" -p $pids/app-0.pid
mon -d "node $app/jobs" -p $pids/jobs-0.pid
mon -d "node $app/jobs" -p $pids/jobs-1.pid
mon -d "node $app/jobs" -p $pids/jobs-2.pid
mon -d "node $app/image" -p $pids/image-0.pid
mon -d "node $app/image" -p $pids/image-1.pid
mon -d "node $app/image-broker" -p $pids/image-broker.pid
```
9 changes: 9 additions & 0 deletions example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

echo one
sleep 2
echo two
sleep 2
echo three
sleep 2
echo exiting
exit 1
Loading

0 comments on commit e1c23b4

Please sign in to comment.