mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
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.
100 lines
4.0 KiB
Plaintext
100 lines
4.0 KiB
Plaintext
---
|
|
layout: docs
|
|
page_title: Install Nomad as a Windows service
|
|
description: |-
|
|
Learn how to run Nomad as a Windows service. Register Nomad with the Windows Service Control Manager. Configure Nomad to log to file, and increase the non-interactive desktop heap size.
|
|
---
|
|
|
|
# Install Nomad as a Windows 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.
|
|
|
|
## Register Nomad with Windows
|
|
|
|
[Download] the Nomad binary for your architecture.
|
|
|
|
Use the [`sc.exe`] command to create a Service named "Nomad". The binPath
|
|
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] CreateService SUCCESS
|
|
```
|
|
|
|
If you receive a success message, your service is registered with the service
|
|
manager.
|
|
|
|
If you get an error, please verify the path to the binary and check the
|
|
arguments, by running the contents of `binPath` directly in a PowerShell session
|
|
and observing the results.
|
|
|
|
## Configure Nomad to log to file
|
|
|
|
Because Windows services run non-interactively and Nomad does not log to the
|
|
Windows Event Viewer, you will need to configure file-based logging in Nomad.
|
|
|
|
To do this, set the [`log_file`][logging] argument in your Nomad configuration
|
|
file or in the binPath argument of the [`sc.exe`] command used to register the
|
|
service.
|
|
|
|
## Start the Nomad service
|
|
|
|
You have two ways to start the service.
|
|
|
|
- Go to the Windows Service Manager, and look for **Nomad** in the service name
|
|
column. Click the _Start_ button to start the service.
|
|
|
|
- Using the [`sc.exe`] command:
|
|
|
|
```plaintext
|
|
sc.exe start "Nomad"
|
|
|
|
SERVICE_NAME: Nomad
|
|
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 Nomad from the command-line again.
|
|
|
|
## Increase the non-interactive desktop heap size
|
|
|
|
If you run Nomad as a Windows service and you intend to run many allocations,
|
|
such as more than 50, you may encounter issues with Windows terminating Nomad
|
|
plugin processes with errors such as `exit status 0xc0000142` appearing in the
|
|
logs. This is due to Nomad's inability to spawn more concurrent processes, and
|
|
you may fix this by manipulating the value of
|
|
`HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
|
|
Manager\SubSystems` Windows registry key.
|
|
|
|
This key has a `Windows` value which in turn has a `SharedSection` parameter
|
|
that accepts a value of three comma-separated integers, for example,
|
|
`1024,20480,768`. The first integer indicates the maximum size of the
|
|
system-wide heap, the second is the size of each desktop heap, and the third is
|
|
the size of the desktop heap that is associated with a noninteractive Windows
|
|
instance. All values are in kilobytes. For large Windows nodes that run large
|
|
numbers of allocations, we recommend setting the final integer value to 2048 or
|
|
4096 kB. Remember that any registry change requires restarting Windows, a
|
|
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
|