mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
[cli] Add windows service commands (#26442)
Adds a new `windows` command which is available when running on a Windows hosts. The command includes two new subcommands: * `service install` * `service uninstall` The `service install` command will install the called binary into the Windows program files directory, create a new Windows service, setup configuration and data directories, and register the service with the Window eventlog. If the service and/or binary already exist, the service will be stopped, service and eventlog updated if needed, binary replaced, and the service started again. The `service uninstall` command will stop the service, remove the Windows service, and deregister the service with the eventlog. It will not remove the configuration/data directory nor will it remove the installed binary.
This commit is contained in:
@@ -129,6 +129,10 @@ You may, however, may pass the following configuration options as CLI arguments:
|
||||
- `-encrypt`: Set the Serf encryption key. See the [Encryption Overview][] for
|
||||
more details.
|
||||
|
||||
- `-eventlog`: Equivalent to the [eventlog.enabled][] config option.
|
||||
|
||||
- `-eventlog-level`: Equivalent to the [eventlog.level][] config option.
|
||||
|
||||
- `-join=<address>`: Address of another agent to join upon starting up. This can
|
||||
be specified multiple times to specify multiple agents to join.
|
||||
|
||||
@@ -231,6 +235,8 @@ You may, however, may pass the following configuration options as CLI arguments:
|
||||
[datacenter]: /nomad/docs/configuration#datacenter
|
||||
[enabled]: /nomad/docs/configuration/acl#enabled
|
||||
[encryption overview]: /nomad/docs/secure/traffic/gossip-encryption
|
||||
[eventlog.enabled]: /nomad/docs/configuration#eventlog_enabled
|
||||
[eventlog.level]: /nomad/docs/configuration#eventlog_level
|
||||
[key_file]: /nomad/docs/configuration/consul#key_file
|
||||
[log_include_location]: /nomad/docs/configuration#log_include_location
|
||||
[log_json]: /nomad/docs/configuration#log_json
|
||||
|
||||
22
website/content/commands/windows/index.mdx
Normal file
22
website/content/commands/windows/index.mdx
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
layout: docs
|
||||
page_title: 'nomad windows command reference'
|
||||
description: |
|
||||
The `nomad windows` command interacts with the Windows host platform. Install or uninstall Nomad as a Windows service.
|
||||
---
|
||||
|
||||
# `nomad windows` command reference
|
||||
|
||||
Use the `windows` command to interact with Windows host platforms.
|
||||
|
||||
## Usage
|
||||
|
||||
Usage: `nomad windows <subcommand> [options]`
|
||||
|
||||
Run `nomad windows <subcommand> -h` for help on that subcommand. The following subcommands are available:
|
||||
|
||||
- [`windows service install`][install] - Install Nomad as a Windows service
|
||||
- [`windows service uninstall`][uninstall] - Uninstall Nomad as a Windows service
|
||||
|
||||
[install]: /nomad/commands/windows/service-install
|
||||
[uninstall]: /nomad/commands/windows/service-uninstall
|
||||
50
website/content/commands/windows/service-install.mdx
Normal file
50
website/content/commands/windows/service-install.mdx
Normal file
@@ -0,0 +1,50 @@
|
||||
---
|
||||
layout: docs
|
||||
page_title: 'nomad windows service install command reference'
|
||||
description: |
|
||||
The `nomad windows service install` command installs the Nomad binary
|
||||
and creates a Windows service.
|
||||
---
|
||||
|
||||
# `nomad windows service install` command reference
|
||||
|
||||
The `windows service install` command installs the Nomad binary and
|
||||
creates a Windows service.
|
||||
|
||||
## Usage
|
||||
|
||||
```plaintext
|
||||
nomad windows service install
|
||||
```
|
||||
|
||||
The `windows service install` command installs the `nomad` binary used to
|
||||
run this command, creates a data and configuration directory, writes a basic
|
||||
Nomad configuration file, creates a Windows service to run Nomad, and
|
||||
registers the service with Windows Event Log.
|
||||
|
||||
If Nomad has been previously installed using this command, subsequent
|
||||
executions will do the following:
|
||||
|
||||
1. Stop the service if it is running
|
||||
1. Install the currently executing nomad binary
|
||||
1. Ensure data and configuration directories exist
|
||||
1. Write a configuration file if no configuration files are found
|
||||
1. Update the service if needed
|
||||
1. Update the Event Log configuration if needed.
|
||||
|
||||
## Options
|
||||
|
||||
- `-config-dir <dir>`: Directory to hold the Nomad agent configuration.
|
||||
Defaults to "{{.ProgramFiles}}\HashiCorp\nomad\bin"
|
||||
|
||||
- `-data-dir <dir>`: Directory to hold the Nomad agent state. Defaults
|
||||
to "{{.ProgramData}}\HashiCorp\nomad\data"
|
||||
|
||||
- `-install-dir <dir>`: Directory to install the Nomad binary. Defaults
|
||||
to "{{.ProgramData}}\HashiCorp\nomad\config"
|
||||
|
||||
- `-reinstall`: Allow the nomad Windows service to be stopped during install.
|
||||
|
||||
## General options
|
||||
|
||||
@include 'general_options.mdx'
|
||||
22
website/content/commands/windows/service-uninstall.mdx
Normal file
22
website/content/commands/windows/service-uninstall.mdx
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
layout: docs
|
||||
page_title: 'nomad windows service uninstall command reference'
|
||||
description: |
|
||||
The `nomad windows service uninstall` command removes the Nomad
|
||||
Windows service.
|
||||
---
|
||||
|
||||
# `nomad windows service uninstall` command reference
|
||||
|
||||
The `windows service uninstall` command removes the Nomad Windows service.
|
||||
|
||||
## Usage
|
||||
|
||||
```plaintext
|
||||
nomad windows service uninstall
|
||||
```
|
||||
|
||||
The `windows service uninstall` command stops the Nomad service if
|
||||
it is currently running, deregisters the service with the Windows Event Log,
|
||||
and removes the Windows service. This command does not remove the installed
|
||||
Nomad binary or the data and configuration directories.
|
||||
@@ -176,6 +176,16 @@ testing.
|
||||
This option only works on Unix based systems. The log level inherits from
|
||||
the Nomad agent log set in `log_level`
|
||||
|
||||
- `eventlog` - This is a nested object that configures the behavior with
|
||||
with Windows Event Log. The following parameters are available:
|
||||
|
||||
- `enabled` - Enable sending Nomad agent logs to the Windows Event Log.
|
||||
|
||||
- `level` - `(string: "ERROR")` - Specifies the verbosity of logs the Nomad
|
||||
agent outputs. Valid log levels include `ERROR`, `WARN`, or `INFO` in
|
||||
increasing order of verbosity. Level must be of equal or less verbosity as
|
||||
defined for the [`log_level`](#log_level) parameter.
|
||||
|
||||
- `http_api_response_headers` `(map<string|string>: nil)` - Specifies
|
||||
user-defined headers to add to the HTTP API responses.
|
||||
|
||||
|
||||
@@ -7,9 +7,12 @@ description: |-
|
||||
|
||||
# Install Nomad as a Windows service
|
||||
|
||||
Nomad can be run as a native Windows service. In order to do this, you will need
|
||||
to register the Nomad application with the Windows Service Control Manager using
|
||||
[`sc.exe`], configure Nomad to log to a file, and then start the Nomad service.
|
||||
You may run Nomad as a native Windows service. Use the [windows service install][]
|
||||
command to install Nomad and create the Windows service.
|
||||
|
||||
You may also set up the Nomad Windows service manually. Use [`sc.exe`] to register
|
||||
the Nomad application with the Windows Service Control Manager, configure Nomad to
|
||||
log to a file, and then start the Nomad service.
|
||||
|
||||
~> **Note:** These steps should be run in a PowerShell session with Administrator
|
||||
capabilities.
|
||||
@@ -23,7 +26,7 @@ argument should include the fully qualified path to the Nomad executable and any
|
||||
arguments to the nomad command: agent, -config, etc.
|
||||
|
||||
```plaintext
|
||||
sc.exe create "Nomad" binPath="«full path to nomad.exe» agent -config=«path to config file or directory»" start= auto
|
||||
sc.exe create "Nomad" binPath="«full path to nomad.exe» agent -config=«path to config file or directory»" start=auto
|
||||
[SC] CreateService SUCCESS
|
||||
```
|
||||
|
||||
@@ -93,3 +96,4 @@ restart of Nomad service is not sufficient.
|
||||
[`sc.exe`]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682107(v=vs.85).aspx
|
||||
[download]: /nomad/downloads
|
||||
[logging]: /nomad/docs/configuration#log_file
|
||||
[windows service install]: /nomad/docs/commands/windows/service-install
|
||||
|
||||
@@ -1053,5 +1053,22 @@
|
||||
"path": "volume/status"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "windows",
|
||||
"routes": [
|
||||
{
|
||||
"title": "Overview",
|
||||
"path": "windows"
|
||||
},
|
||||
{
|
||||
"title": "service install",
|
||||
"path": "windows/service-install"
|
||||
},
|
||||
{
|
||||
"title": "service uninstall",
|
||||
"path": "windows/service-uninstall"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user