Step 1

Step 2

Step 3

Change {{USERNAME}} in the script to the user you use in ubuntu to run your app and change {{APPNAME}} to binary name in your $GOPATH/bin/, if needed fix the path in cmd variable to point to your own $GOPATH folder

Step 4

Rename the service remove ending ‘.sh’ and copy the service file in the folder /etc/init.d/

Step 5

Run in the terminal chmod 700 /etc/init.d/goappservice

Step 6

Run sudo update-rc.d goappservice defaults

Step 7

Run sudo update-rc.d goappservice enable

Done!

Use usual service commands to work with your new service.

sudo service goappservice start|stop|restart|status

If there is a new version of the app then just run go install in the app folder and restart the service.