-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Document Windows service using NSSM #758
Comments
We have some experience using WSW + Chocolatey on our Windows clients. I On Wed, Mar 4, 2015 at 6:09 PM, Armon Dadgar notifications@github.com
|
That is, winsw: https://github.com/kohsuke/winsw |
That would be great, I do get this question a lot. We should consider maybe a "Using Windows" guide for some of the oddities on that platform |
I like NSSM, I use it to run Consul and Heka on production Windows servers. A "Using Windows" guide would be much appreciated, I'm running mine in exactly the same config as Linux and it seems ok, but I'm not sure what to look for performancewise. As a reference, here's my Salt states for what I'm doing for NSSM (with a lot of snipping): {% if grains['num_cpus'] == 1 %}
{% set GOMAXPROCS = 2 %}
{% else %}
{% set GOMAXPROCS = grains['num_cpus'] %}
{%- endif -%}
Ensure Consul service is registered:
cmd.run:
- name: |
C:\opt\nssm.exe install consul "C:\opt\consul\consul.exe" agent -config-dir "c:\opt\consul\consul.d"
- unless: sc query consul
Ensure GOMAXPROCS is set to the number of CPUs:
cmd.run:
- shell: powershell
- name: |
C:\opt\nssm.exe set consul AppEnvironmentExtra GOMAXPROCS={{ GOMAXPROCS }}
- unless: |
if ($(C:\opt\nssm.exe get consul AppEnvironmentExtra).Contains("GOMAXPROCS={{ GOMAXPROCS }}")) {exit 0}; exit 1
Ensure negative DNS resolutions are not cached:
cmd.run:
- name: |
C:\Windows\System32\reg.exe add HKLM\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters /v MaxNegativeCacheTtl /t REG_DWORD /d 0 /f
- unless: |
C:\Windows\System32\reg.exe query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DNSCache\Parameters /v MaxNegativeCacheTtl | findstr /C:0x0
Ensure DNS Client is restarted:
module.wait:
- name: service.restart
- m_name: Dnscache
- onchanges:
- cmd: Ensure negative DNS resolutions are not cached
Ensure Consul firewall TCP port is open:
win_firewall.add_rule:
- name: Consul Serf LAN
- localport: 8301
Ensure Consul firewall UDP port is open:
win_firewall.add_rule:
- name: Consul Serf LAN UDP
- localport: 8301
- protocol: udp
Ensure Consul service is started:
service.running:
- name: consul
- enable: true
{% if grains['os'] != 'Windows' %}
- reload: true
{% endif %} |
That is a seriously awesome config! |
Oh and I didn't say it but I'd be happy to help with the docs as well. |
@highlyunavailable Please go for it: your NSSM setup is cooler than our WinSW config. 😄 |
@armon Just want to let you know that we are working to build a MSI package with NSSM and consul.exe running as an automatic build at AppVeyor. I'm sure I can get this open sourced very soon. |
Not quite as nice as @highlyunavailable but we've got a similar Deploy.ps1 script for our Octopus Deploy rollout:
We use a separate deployment step to set the environment var |
I've recently created a WiX/.msi installer for Consul that we use internally (before I found this thread). Would there be interest for adding it upstream? It uses winsw rather than nssm, though, since nssm warns about having multiple instances of it, and saltstack bundles it already. |
In the meantime we also have created a WiX MSI package for Consul using nssm.exe. We don't have problem with multiple nssm.exe as we install it per microservice for a dozen of MSI packages running on one machine. |
@carlpett @StefanScherer I would be interested in seeing both these packages. I'm in the process of configuring consul agent on a Windows server. |
@vLifeOfBrian: I will do some minor cleanup to get rid of some specifics, then get a PR up later today. |
@vLifeOfBrian @carlpett I was allowed to open source parts of our MSI build process. I've put it into an extra repo that can build the MSI package and deploy it as GitHub release as an example. All done at AppVeyor CI. Have a look at https://github.com/StefanScherer/consul-agent, an AppVeyor build badge is also there to see what happens in CI. |
In the meantime I pushed five versions and let AppVeyor build all the MSI's for the different Consul versions to show/test upgrades, blocking downgrades etc. |
Took some extra time due to work-related stuff, but here's our take: #1640 |
@carlpett Thanks for sharing! Looks pretty good. Our setup with the I also have removed the code signing steps we have to sign both the A missing step are some tests with the MSI. I plan to add some at work and share them as well in the public repo soon. |
@carlpett - this is a great setup! In my team we need a custom consul.json with a specific local bind_addr in place of the loopback advertise_addr. Thanks, |
@vassilvk - Thanks! The service is installed with the |
Thanks, @carlpett. |
Hi We were having a similar conversation in one of the InfluxData Telegraf Github issues (influxdata/telegraf#860) and @StianOvrevage mentioned https://godoc.org/bosun.org/cmd/scollector has a -winsvc flag which makes the binary register correctly as a Windows Service. https://github.com/bosun-monitor/bosun/blob/master/cmd/scollector/service_windows.go seems to do the magic. @slackpad @mitchellh Would you consider adding something similar to make running the Consul agent a bit easier in Windows machines? NSSM works great but it certainly seems a bit of a hack |
Any updates on this. Would love to have a known process for windows |
Having recently come across this issue, we're using the Chocolatey supplied packge. Using Ansible to install the service and then set the appropriate config files (as a client). Works a treat! |
It would be great if the |
By importing |
Nice trick. Thanks @pieterlouw |
#4244 Fixes this. |
Just came across this, seems suitable to run Consul as a service.
http://nssm.cc
The text was updated successfully, but these errors were encountered: