Could I apply this daemon guide to go?

blov · 2016-07-02 09:00:21 · 592 次点击    
这是一个分享于 2016-07-02 09:00:21 的资源,其中的信息可能已经有所发展或是发生改变。

So I've been tinkering with go for the past two weeks and I've been trying to figure out what the easiest way to serve my http server application as a daemon. The search results were pretty much over my head, so I took go out of the picture and came across this guide

Could I apply this guide to a go server? I haven't had time to try it yet, but I guess the best place to ask would be here.


评论:

kardianos:

If you are struggling with a simple default, you could use the package github.com/kardianos/service which will let you run it as a service on windows/osx/systemd/sysv with the same code base.

SaltTM:

wish that was a bit more documented, but I assume using runner would do what i wanted

Frakturfreund:

Yes, you can. But parts of it seems to be a little outdated; both Ubuntu and Debian have switched to systemd (like Arch Linux).

the_jester:

Broadly speaking, yes. Your software may want to have some "good habits", in terms of pidfile handling, and catching signals gracefully, but even if it does not, all those listed process managers are agnostic. They don't care if your program is in C, Python, or Go.

pschlump:

In 1.5 of Go I had a bunch of problems with go-routines not working happily when combined with begin a service and a Linux chroot. My solution was a C wrapper that started and managed the Go code. I am not certain if the problems were fixed in 1.6+ of Go. This related to changing of ownership of sub-processes and not changing all the threads in the Go Program - thereby leaving some threads running as root. This would not apply to Windows - if on windows use the github.com/kardianos/service package - it works. If on linux you might consider: github.com/pschlump/daemon-it


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

592 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传