-
Setup Go cross-compile using Dave Cheney's instructions & package.
-
Copy the
myapp.conffile to/etc/init/myapp.conf. Change the name of the service to whatever you want to call it. -
Change the name parameter in
myapp.confto your application's name. -
Change the
script/end scriptblock to whatever you need to startup your app.
To start your service:
$ sudo service myapp startTo stop your service:
$ sudo service myapp stopYou can find STDOUT automatically logged to /var/log/upstart/myapp.log.
When you deploy, you'll need to stop the service, copy over the binary, and then start the service again.
You can use goxc and create a deb file but I think that's overkill since it's a single binary.
I usually create a data directory under /var/lib/myapp and I store my configuration under /etc/myapp/.