<p>I'm pretty fresh to this, but I built a small webservice that Responds to JSON posts and compiled it as an exe. I'd like to run it as a local windows service and I don't want to use any outside programs. I know outside programs exist to run exe as service, like NSSM, but it is a server that I'd like to avoid outside programs on and I'd like to know the "correct" way to go about this.</p>
<p>It looks like the exe must implement the ServiceMain callback function.
<a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms685138(v=vs.85).aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/windows/desktop/ms685138(v=vs.85).aspx</a></p>
<p>It would be cool if there was an option when compiling it also. Does anyone have experience doing this?</p>
<hr/>**评论:**<br/><br/>lordnins: <pre><p>I'm using <a href="https://github.com/kardianos/service" rel="nofollow">https://github.com/kardianos/service</a> you should check it out</p></pre>Hexodam: <pre><p>That or this <a href="https://nssm.cc/" rel="nofollow">https://nssm.cc/</a></p></pre>cesarliws: <pre><p>have you looked this:</p>
<p><a href="https://github.com/golang/sys/blob/master/windows/svc/example/service.go" rel="nofollow">https://github.com/golang/sys/blob/master/windows/svc/example/service.go</a></p></pre>sleepyj222: <pre><p>I haven't, I'll check it out closer. Thanks!</p></pre>binaryblade: <pre><p><a href="http://maradns.blogspot.ca/2009/03/ive-got-working-windows-service-running.html?m=1" rel="nofollow">here</a> is a link to a very small c program that does it. Should be adaptable into go.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传