[docs] Windows Guide (#5626)

* Updating the windows guide for the migration.

* adding config dir option
This commit is contained in:
kaitlincarter-hc 2019-04-16 16:14:10 -05:00 committed by GitHub
parent 9c7c8eb4a8
commit 5448b1a026
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 40 additions and 39 deletions

View File

@ -7,65 +7,66 @@ description: |-
the Windows command line, you can make Consul run as a service. For more details about the _sc_ command the Windows command line, you can make Consul run as a service. For more details about the _sc_ command
the Windows page for [sc](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682107(v=vs.85).aspx) the Windows page for [sc](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682107(v=vs.85).aspx)
should help you get started. should help you get started.
--- ---
# Overview # Run Consul as a Service on Windows
By using the _sc_ command either on Powershell or
the Windows command line, you can make Consul run as a service. For more details about the _sc_ command 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](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682107(v=vs.85).aspx) the Windows page for [sc](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682107(v=vs.85).aspx)
should help you get started. should help you get started.
Please remember to create a permanent directory for storing the configuration files. It is always 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 `-config-dir` option.
advisable to start Consul with the _-config-dir_ option.
The steps presented here , we assume that the user has launched Powershell with _Adminstrator_ capabilities. In this guide, you will download the Consul binary, register the Consul service
with the Service Manager, and finally start Consul.
## Running Consul run as a service on Windows The steps presented here, assume that you have launched Powershell with _Adminstrator_ capabilities.
### Installing Consul as a Service ## Installing Consul as a Service
Download the Consul binary for your architecture. Download the Consul binary for your architecture.
Use the _sc_ command to create a Service named **Consul**, which starts in the _dev_ mode. Use the _sc_ command to create a service named **Consul**, that will load configuration files from the `config-dir`. Read the agent configuration
[documentation](/docs/agent/options.html#configuration-files) to learn more about configuration options.
```text ```text
sc.exe create "Consul" binPath= "Path to the Consul.exe arg1 arg2 ...argN" start= auto sc.exe create "Consul" binPath= "<path to the Consul.exe> -config-dir <path to configuration directory>" start= auto
[SC] CreateService SUCCESS [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 output that is similar to the one above, then your service is If you get an error, please check that
registered with the Service manager. you have specified the proper path to the binary and check if you've entered the arguments correctly for the Consul service.
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 ## Running Consul as a Service
You have two ways to start the service. You have two options for starting the service.
* Go to the Windows Service Manager, and look for **Consul** under the 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.
service name. Click the _start_ button to start the service.
* Using the _sc_ command: The second option is to use the _sc_ command.
```text ```text
sc.exe start "Consul" sc.exe start "Consul"
SERVICE_NAME: Consul SERVICE_NAME: Consul
TYPE : 10 WIN32_OWN_PROCESS TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING STATE : 4 RUNNING (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
(STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0)
WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0
CHECKPOINT : 0x0 WAIT_HINT : 0x0
WAIT_HINT : 0x0 PID : 8008
PID : 8008 FLAGS :
FLAGS : ```
```
The service automatically starts up during/after boot, so you don't need to The service automatically starts up during/after boot, so you don't need to
launch Consul from the command-line again. launch Consul from the command-line again.
## Summary
In this guide you setup a Consul service on Windows. This process can be repeated to setup an entire cluster of agents.