consul.exe as a Windows service

4,776 views
Skip to first unread message

Alex Schukin

unread,
Nov 19, 2014, 1:41:36 AM11/19/14
to consu...@googlegroups.com
Hi All,
I'm trying to run Consul.exe as a Windows service because I need a service that works in "non-stop" mode (automatic restart on a failure, control by OS on startup/shutdown).

Thus, I created my service using the following command:
sc create "Consul" binPath= "C:\consul.io\consul.exe agent -config-dir "c:\consul.io\consul.d\bootstrap" --ui-dir "c:\consul.io\ui"" type= share start= auto

Config file:
c:\consul.io\consul.d\bootstrap\config.json
{
   
"bootstrap": true,
   
"server": true,
   
"datacenter": "RG",
   
"data_dir": "c:\\consul.io\\data\\",
   
"ui_dir": "c:\\consul.io\\ui",
   
"encrypt": "U+ff6ZZlI7Zm4w2oHWVCSg==",
   
"log_level": "Trace"
}

But this service cannot be started as it does not respond to the start or control Windows requests.

Do I understand correctly that consul.exe windows binary file does not support Windows service methods? If so, how can I use consule on Windows like an unix daemon?

Thank you,
    Alex

Ryan Breen

unread,
Nov 19, 2014, 8:38:00 PM11/19/14
to Alex Schukin, consu...@googlegroups.com
We use a service wrapper (https://github.com/kohsuke/winsw or http://nssm.cc/) around the Consul binary.  Works well enough.

Ryan

--
You received this message because you are subscribed to the Google Groups "Consul" group.
To unsubscribe from this group and stop receiving emails from it, send an email to consul-tool...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Schukin

unread,
Nov 20, 2014, 1:42:22 AM11/20/14
to consu...@googlegroups.com, schukin....@gmail.com
Thanks much! I've already tried nssm wrapper and it works fine.

четверг, 20 ноября 2014 г., 4:38:00 UTC+3 пользователь Ryan Breen написал:

Brad Aisa

unread,
May 18, 2015, 7:30:06 PM5/18/15
to consu...@googlegroups.com, schukin....@gmail.com
Ryan I'm curious about how you shut down consul.exe -- one of our engineers has been adamant that the alleged "graceful" shutdown (via Ctrl-C) is actually disastrous in practice, and wants us to shut it down using the Ctrl-Break interrupt. (He said that the "graceful" shutdown actually causes the node to leave the cluster and he said this can cause corruption and a situation where there is no master -- fyi I'm not that expert yet on consul.) The problem is that nssm can only send Ctrl-C.

Can you comment on how you shut down consul when you have it running as a service, and have you experienced issues if you use Ctrl-C for the (alleged) "graceful" shutdown.

Ryan Breen

unread,
May 18, 2015, 8:37:27 PM5/18/15
to Brad Aisa, consu...@googlegroups.com, Alex Schukin
Interesting.  We use NSSM and the Ctrl-C behavior.  I believe Ctrl-C is interpreted by Consul identically on both Windows and Unix, and I can't agree with the estimation that it's disastrous.  When you shutdown a node, you want it to leave the cluster.  You could wind up in a situation where there's no master only if you shut down enough nodes, at the exact same time, that you no longer have a quorum.  But the answer to that is not "shut down Consul in such a way that the cluster doesn't know you shut it down" but is instead "don't shut down all your servers at the same time." :-)
Reply all
Reply to author
Forward
0 new messages