-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Http Server as windows service #108
Comments
@charliemaiors I'm facing the same issue. Did you find some workaround? Thanks |
I was using nssm previously and I don't want to use it anymore. I'll try to find out a solution. Thank you anyway. |
For Windows, the main function must be the fastest possible so as to return very quickly a kind of ack to the OS. So you shouldn't do some many operations such as initialising things but be as brief as possible. Loading configuration, initialising stuffs and doing the job should be delegated to another function that is the service. See an example here (in French, but the sample code is commented on English): http://decouvric.cluster013.ovh.net/golang/thirdparty/divers/creer-un-service-golang-avec-kardianos.html |
Thanks. But I can't understand when the function s.Run is getting called? |
The part of code where s.Run is used is the service itself. As you can see, s.Run is called very quickly (nothing big is initialised before the call and no parameter is given to a Windows service). This is the pattern you must follow if you want to code a Windows service. |
My HTTP is unreachable when running under Windows service, even via localhost. Works fine if not running under Windows service. My s.Run is fast and and there is no error that I can see in the Windows Event logs. Has anybody encountered this? |
Check your system firewall.
…On Mon, May 14, 2018, 19:16 Nuri ***@***.***> wrote:
My HTTP is unreachable when running under Windows service, even via
localhost. Works fine if not running under Windows service. My s.Run is
fast and and there is no error that I can see in the Windows Event logs.
Has anybody encountered this?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#108 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAuFsZ8cjD-KJ7l5Z9tZIat9unW41j-3ks5tyjqJgaJpZM4QadAk>
.
|
Yes, I looked at that and couldn't see anything wrong. If the firewall was the issue, the service would be blocked when running stand-alone (not as Windows service), but it works fine that way. |
Windows Firewall can block the network port used by your service, even when accessed from localhost to localhost. Try to disable it, if it is the root cause, allow the port. |
When your program is executed as a stand alone process, it doesn't use the same account than when it runs as a service (so the level of privileges and the context differ). |
@mahaben did you find a solution for this? I'm having the same issue. |
Your start function must return in milliseconds. |
Hi I have the same problem. If there is nothing to do everything work. As soon as I add an http server I get the 1053 error:
Thank you for your help. |
Maybe "webserver.StartWebserver()" is panicing? Does it work if you comment that out? |
You are right. It was a panic, that was just occuring if it was running as service. I solved the problem and now everthing works great. Thank you for your fast help and your great package! |
how you solved it? i have the same issue |
I am sorry I could not find any more code for this. |
Hi, I've defined simple service which stars an HTTP server I've defined the service installation here but when I try to start service from PowerShell or simple services.msc it will return the error 1053: the service did not respond to the start or control request in a timely fashion.
The text was updated successfully, but these errors were encountered: