File this under "I can't believe how long it took me to figure it out".
some of our services at work. One of them (by design) kills itself after handling a number of requests. Of course, I want it to restart after it kills itself. Most solutions seem like overkill. Using a service supervisor like runit
is great, but requires too much setup for monitoring just a single process.Forever
is probably a good option, but I don't want to have to install Node.js in the image just to monitor it. Not to mention, Node.js has a non-trivial memory footprint.
Basically, I want something small and simple. No extra dependencies, minimal extra setup, minimal extra resource usage. After too much time looking for a solution, I came up with a 5-line shell script:
Name it forever.sh and put it in your PATH, and use it as: forever.sh (e.g. forever.sh server -p 8080). It's just an infinite loop that executes its arguments until it gets killed.0 Comments