英文:
how to keep Go webservice running
问题
我正在一个Linux机器上用Go编写一些Web服务,所以Go可执行文件需要保持运行状态。
哪种方式是最好的呢?
我应该将Go可执行文件设置为Linux机器上的服务吗?
非常感谢。
英文:
I am writing some webservices in Go on a linux machine, so the Go executable needs to keep running
which is the best way to do it?
should I setup the Go executable as a service on the linux machine?
many thanks
答案1
得分: 2
简短回答:如果你想保持事情非常简单,可以使用系统服务管理器。CentOS目前使用的是Upstart,它有很好的文档,并且可以处理大多数Go应用程序而不会出现太多问题。这里有一些很好的Upstart + Go的例子:这里和这里。
长回答:个人偏好。Supervisord、Monit和Circus也是不错的选择,但它们带来了不同程度的复杂性。我个人喜欢supervisord,因为它有相当清晰的语法和很多选项。
这里也有一个很好的概述:http://tech.cueup.com/blog/2013/03/08/running-daemons/
英文:
The short answer: use the system service manager if you want to keep things super-simple. CentOS currently uses Upstart, and it's well documented and can handle most Go applications without too many problems. There are some good examples of Upstart + Go here and here
The long answer: personal preference. Supervisord, Monit and Circus are good options as well, but bring differing levels of complexity. I personally like supervisord, since it has a fairly clear syntax and a good heap of options.
There's also a good run-down here: http://tech.cueup.com/blog/2013/03/08/running-daemons/
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论