A Simple Way to Keep a Go App Up and Running

Poor man’s Kubernetes

1 min read

Poor man’s Kubernetes

I am a lazy programmer, experimenting with new ideas all the time. For these, running and deploying tiny Go apps as single executables is the closest way to see something in action. Yet, quickly written Go apps often panic, and crash altogether. While I am a strong defender of making sure that all possible errors are checked, real software is bound to eventually crash, no matter what. In such situations, the fastest solution is usually a simple restart.

Systemd, Docker, Kubernetes - all took process supervision to a new level. If you are working on production-level software, chances are you already have some infrastructure layer in place that will take care of this. On the other hand, setting up tons of infrastructure is the last thing you want to think about, when working on your quickly made side project. This is where the following 5-line Bash script comes in place:


while true; do

# call this file run.sh and use nohup to start it
# nohup ./run.sh &

That’s it. Instead of running your app directly, you can use nohup to run it through the Bash script: nohup run.sh &.

NOTE: While fairly easy to set up, this is by no means a safe way to take care of process restarts. It is also not an excuse to avoid thorough error checking. It will help you see your app quickly, but as soon as it starts getting serious traffic, you need to consider setting up the proper infrastructure. I can help with that.

Related Articles

Elixir Tip: Case vs. With
3 min read

Elixir Is Not Ruby. Elixir Is Erlang

Try to remember the first time you heard about this fascinating language called Elixir. Chances are, you had by the

2 min read

Write Stupid Code

This is very much a re-interpretation of a post by Thorsten Ball, written back in 2015. Like him, I too

1 min read