如何保持Go Web服务运行

huangapple go评论127阅读模式
英文:

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的例子:这里这里

长回答:个人偏好。SupervisordMonitCircus也是不错的选择,但它们带来了不同程度的复杂性。我个人喜欢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/

huangapple
  • 本文由 发表于 2013年8月4日 09:18:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/18038881.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定