How to start a Go program as a daemon in Ubuntu?
go
Solution
You should build an executable for your program (`go build`) and then either write a script for upstart and it will run your program as a daemon for you, or use an external tool like daemonize. I prefer the latter solution, because it does not depend on a system-dependent upstart. With daemonize you can start your application like
daemonize -p /var/run/myapp.pid -l /var/lock/subsys/myapp -u nobody /path/to/myapp.exe
This will give you a well-behaving unix daemon process with all necessary daemon preparations done by daemonize.
Problem
What is the proper way to start a Go program as a daemon in Ubuntu ? I will then monitor it with Monit. Should I just do something like: ``` go run myapp.go & ``` Are there things specific to Go that I should take into account ?