By using the sc command, either on Powershell or the Windows command line, you can run Consul as a service. For more details about the sc command the Windows page for sc should help you get started.
Before installing Consul, you will need to create a permanent directory for storing the configuration files. Once that directory is created, you will set it when starting Consul with the
In this tutorial, you will download the Consul binary, register the Consul service with the Service Manager, and finally start Consul.
The steps presented here, assume that you have launched Powershell with Administrator capabilities.
»Installing Consul as a service
Download the Consul binary for your architecture.
Use the sc command to create a service named Consul, that will load configuration files from the
config-dir. Read the agent configuration
documentation to learn more about configuration options.
sc.exe create "Consul" binPath= "<path to the Consul.exe> agent -config-dir=<path to configuration directory>" start= auto [SC] CreateService SUCCESS
If you get an output that is similar to the one above, then your service is registered with the Service Manager.
If you get an error, please check that you have specified the proper path to the binary and check if you've entered the arguments correctly for the Consul service.
»Running Consul as a service
You have two options for starting the service.
The first option is to use the Windows Service Manager, and look for Consul under the service name. Click the start button to start the service.
The second option is to use the sc command.
sc.exe start "Consul" SERVICE_NAME: Consul TYPE : 10 WIN32_OWN_PROCESS STATE : 4 RUNNING (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 PID : 8008 FLAGS :
The service automatically starts up during/after boot, so you don't need to launch Consul from the command-line again.
In this tutorial, you setup a Consul service on Windows. This process can be repeated to setup an entire datacenter of agents.