Could I apply this daemon guide to go?

blov · · 378 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>So I&#39;ve been tinkering with go for the past two weeks and I&#39;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 <a href="https://blog.frd.mn/how-to-set-up-proper-startstop-services-ubuntu-debian-mac-windows/">this guide</a></p> <p>Could I apply this guide to a go server? I haven&#39;t had time to try it yet, but I guess the best place to ask would be here.</p> <hr/>**评论:**<br/><br/>kardianos: <pre><p>If you are struggling with a simple default, you could use the package <code>github.com/kardianos/service</code> which will let you run it as a service on windows/osx/systemd/sysv with the same code base.</p></pre>SaltTM: <pre><p>wish that was a bit more documented, but I assume using runner would do what i wanted</p></pre>Frakturfreund: <pre><p>Yes, you can. But parts of it seems to be a little outdated; both Ubuntu and Debian have switched to systemd (like Arch Linux).</p></pre>the_jester: <pre><p>Broadly speaking, yes. Your software may want to have some &#34;good habits&#34;, in terms of pidfile handling, and catching signals gracefully, but even if it does not, all those listed process managers are agnostic. They don&#39;t care if your program is in C, Python, or Go.</p></pre>pschlump: <pre><p>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</p></pre>

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

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