Skip to content

Commit fe90e93

Browse files
author
Brian Picciano
committed
initial commit
0 parents  commit fe90e93

File tree

7 files changed

+502
-0
lines changed

7 files changed

+502
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pmux

LICENSE.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2+
Version 2, December 2004
3+
4+
Copyright (C) 2004 Sam Hocevar <[email protected]>
5+
6+
Everyone is permitted to copy and distribute verbatim or modified
7+
copies of this license document, and changing it is allowed as long
8+
as the name is changed.
9+
10+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12+
13+
0. You just DO WHAT THE FUCK YOU WANT TO.
14+

README.md

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# pmux
2+
3+
A dumb simple user-space process manager, for use in composing multiple
4+
processes together into a single runable frontend.
5+
6+
Features include (and are limited to):
7+
8+
* Coalesces all stdout and stderr streams of all sub-processes into a single
9+
stdout stream (with timestamps and process names prefixing each line).
10+
11+
* Propagates interrupt signal to sub-processes, and waits a configurable amount
12+
of time before SIGKILLing those which don't exit themselves.
13+
14+
* Will restart processes which unexpectedly exit, with an exponential backoff
15+
delay for those which repeatedly exit.
16+
17+
* Configurable timestamp format.
18+
19+
That's it. If it's not listed then pmux can't do it.
20+
21+
## Usage
22+
23+
To build you just `go build .` within the directory.
24+
25+
To run you do `pmux -c pmux.yml`. If `-c` isn't provided then pmux will look for
26+
`pmux.yml` in the pwd. A config file is required.
27+
28+
## Example
29+
30+
This repo contains [an example config file](pmux-example.yml), which shows off
31+
all possible configuration options.
32+
33+
The output the stream from this example config looks something like this:
34+
35+
```
36+
2021-09-21T16:32:48.513-06:00 | stubborn-pinger | starting process
37+
2021-09-21T16:32:48.513-06:00 | pinger | starting process
38+
2021-09-21T16:32:48.532-06:00 > pinger > PING example.com (93.184.216.34) 56(84) bytes of data.
39+
2021-09-21T16:32:48.532-06:00 > pinger > 64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=1 ttl=55 time=14.1 ms
40+
2021-09-21T16:32:48.532-06:00 > pinger >
41+
2021-09-21T16:32:48.532-06:00 > pinger > --- example.com ping statistics ---
42+
2021-09-21T16:32:48.532-06:00 > pinger > 1 packets transmitted, 1 received, 0% packet loss, time 0ms
43+
2021-09-21T16:32:48.532-06:00 > pinger > rtt min/avg/max/mdev = 14.091/14.091/14.091/0.000 ms
44+
2021-09-21T16:32:48.532-06:00 > stubborn-pinger > PING example.com (93.184.216.34) 56(84) bytes of data.
45+
2021-09-21T16:32:48.532-06:00 > stubborn-pinger > 64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=1 ttl=55 time=14.2 ms
46+
2021-09-21T16:32:48.532-06:00 > stubborn-pinger >
47+
2021-09-21T16:32:48.532-06:00 > stubborn-pinger > --- example.com ping statistics ---
48+
2021-09-21T16:32:48.532-06:00 > stubborn-pinger > 1 packets transmitted, 1 received, 0% packet loss, time 0ms
49+
2021-09-21T16:32:48.532-06:00 > stubborn-pinger > rtt min/avg/max/mdev = 14.154/14.154/14.154/0.000 ms
50+
2021-09-21T16:32:49.548-06:00 > pinger > PING example.com (93.184.216.34) 56(84) bytes of data.
51+
2021-09-21T16:32:49.548-06:00 > pinger > 64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=1 ttl=55 time=10.5 ms
52+
2021-09-21T16:32:49.548-06:00 > pinger >
53+
2021-09-21T16:32:49.548-06:00 > pinger > --- example.com ping statistics ---
54+
2021-09-21T16:32:49.548-06:00 > pinger > 1 packets transmitted, 1 received, 0% packet loss, time 0ms
55+
2021-09-21T16:32:49.548-06:00 > pinger > rtt min/avg/max/mdev = 10.451/10.451/10.451/0.000 ms
56+
2021-09-21T16:32:49.553-06:00 > stubborn-pinger > PING example.com (93.184.216.34) 56(84) bytes of data.
57+
2021-09-21T16:32:49.553-06:00 > stubborn-pinger > 64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=1 ttl=55 time=15.3 ms
58+
2021-09-21T16:32:49.553-06:00 > stubborn-pinger >
59+
2021-09-21T16:32:49.553-06:00 > stubborn-pinger > --- example.com ping statistics ---
60+
2021-09-21T16:32:49.553-06:00 > stubborn-pinger > 1 packets transmitted, 1 received, 0% packet loss, time 0ms
61+
62+
...
63+
64+
^C2021-09-21T16:32:50.894-06:00 | pmux | interrupt signal received, killing all sub-processes
65+
2021-09-21T16:32:50.895-06:00 > stubborn-pinger > i will never stop, you will have to SIGKILL me!
66+
2021-09-21T16:32:50.895-06:00 | pinger | process exited: signal: interrupt
67+
2021-09-21T16:32:50.895-06:00 | pinger | stopped process handler
68+
2021-09-21T16:32:50.910-06:00 > stubborn-pinger > PING example.com (93.184.216.34) 56(84) bytes of data.
69+
2021-09-21T16:32:50.910-06:00 > stubborn-pinger > 64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=1 ttl=55 time=11.4 ms
70+
2021-09-21T16:32:50.910-06:00 > stubborn-pinger >
71+
2021-09-21T16:32:50.910-06:00 > stubborn-pinger > --- example.com ping statistics ---
72+
2021-09-21T16:32:50.910-06:00 > stubborn-pinger > 1 packets transmitted, 1 received, 0% packet loss, time 0ms
73+
2021-09-21T16:32:50.910-06:00 > stubborn-pinger > rtt min/avg/max/mdev = 11.369/11.369/11.369/0.000 ms
74+
2021-09-21T16:32:51.895-06:00 | stubborn-pinger | forcefully killing process
75+
2021-09-21T16:32:51.912-06:00 | stubborn-pinger | process exited: signal: killed
76+
2021-09-21T16:32:51.912-06:00 | stubborn-pinger | stopped process handler
77+
2021-09-21T16:32:51.912-06:00 | pmux | exited gracefully, ciao!
78+
```

go.mod

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module pmux
2+
3+
go 1.16
4+
5+
require gopkg.in/yaml.v2 v2.4.0 // indirect

go.sum

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2+
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
3+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=

0 commit comments

Comments
 (0)