Skip to content

Commit

Permalink
Added Docs
Browse files Browse the repository at this point in the history
* guide for installing as a windows service.
* configuration for logging to file from PR #6429
  • Loading branch information
angrycub authored and tgross committed Nov 11, 2019
1 parent c1af8f6 commit 42c9b1d
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 12 deletions.
47 changes: 35 additions & 12 deletions website/source/docs/configuration/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ testing.

## General Parameters

- `acl` <code>([ACL][acl]: nil)</code> - Specifies configuration which is specific to ACLs.
- `acl` `([ACL][acl]: nil)` - Specifies configuration which is specific to ACLs.

- `addresses` `(Addresses: see below)` - Specifies the bind address for
individual network services. Any values configured in this stanza take
Expand Down Expand Up @@ -130,9 +130,10 @@ testing.
Dev mode (`-dev`) defaults to localhost.
The value supports [go-sockaddr/template format][go-sockaddr/template].

- `client` <code>([Client][client]: nil)</code> - Specifies configuration which is specific to the Nomad client.
- `client` `([Client][client]: nil)` - Specifies configuration which is specific
to the Nomad client.

- `consul` <code>([Consul][consul]: nil)</code> - Specifies configuration for
- `consul` `([Consul][consul]: nil)` - Specifies configuration for
connecting to Consul.

- `datacenter` `(string: "dc1")` - Specifies the data center of the local agent.
Expand All @@ -143,13 +144,16 @@ testing.
allocation data as well as cluster information. Server nodes use this
directory to store cluster state, including the replicated log and snapshot
data. This must be specified as an absolute path.

~> **WARNING**: This directory **must not** be set to a directory that is [included in the chroot](/docs/drivers/exec.html#chroot) if you use the [`exec`](/docs/drivers/exec.html) driver.

~> **WARNING**: This directory **must not** be set to a directory that is
[included in the chroot](/docs/drivers/exec.html#chroot) if you use the
[`exec`](/docs/drivers/exec.html) driver.

- `disable_anonymous_signature` `(bool: false)` - Specifies if Nomad should
provide an anonymous signature for de-duplication with the update check.

- `disable_update_check` `(bool: false)` - Specifies if Nomad should not check for updates and security bulletins.
- `disable_update_check` `(bool: false)` - Specifies if Nomad should not check
for updates and security bulletins.

- `enable_debug` `(bool: false)` - Specifies if the debugging HTTP endpoints
should be enabled. These endpoints can be used with profiling tools to dump
Expand Down Expand Up @@ -179,6 +183,22 @@ testing.

- `log_json` `(bool: false)` - Output logs in a JSON format.

- `log_file` `(string: "")` - Specifies the path for logging. If the path
does not includes a filename, the filename defaults to "nomad-{timestamp}.log".
This setting can be combined with `log_rotate_bytes` and `log_rotate_duration`
for a fine-grained log rotation control.

- `log_rotate_bytes` `(int: 0)` - Specifies the number of bytes that should be
written to a log before it needs to be rotated. Unless specified, there is no
limit to the number of bytes that can be written to a log file.

- `log_rotate_duration` `(duration: "24h")` - Specifies the maximum duration a
log should be written to before it needs to be rotated. Must be a duration
value such as 30s.

- `log_rotate_max_files` `(int: 0)` - Specifies the maximum number of older log
file archives to keep. If 0 no files are ever deleted.

- `name` `(string: [hostname])` - Specifies the name of the local node. This
value is used to identify individual agents. When specified on a server, the
name must be unique within the region.
Expand All @@ -188,7 +208,7 @@ testing.
[data_dir](#data_dir) suffixed with "plugins", like `"/opt/nomad/plugins"`.
This must be an absolute path.

- `plugin` <code>([Plugin][plugin]: nil)</code> - Specifies configuration for a
- `plugin` `([Plugin][plugin]: nil)` - Specifies configuration for a
specific plugin. The plugin stanza may be repeated, once for each plugin being
configured. The key of the stanza is the plugin's executable name relative to
the [plugin_dir](#plugin_dir).
Expand Down Expand Up @@ -221,15 +241,18 @@ testing.
with potentially multiple zones, which map to [datacenters](#datacenter) such
as `us-west` and `us-east`.
- `sentinel` <code>([Sentinel][sentinel]: nil)</code> - Specifies configuration for Sentinel policies.
- `sentinel` `([Sentinel][sentinel]: nil)` - Specifies configuration for Sentinel
policies.
- `server` <code>([Server][server]: nil)</code> - Specifies configuration which is specific to the Nomad server.
- `server` `([Server][server]: nil)` - Specifies configuration which is specific
to the Nomad server.
- `syslog_facility` `(string: "LOCAL0")` - Specifies the syslog facility to write to. This has no effect unless `enable_syslog` is true.
- `syslog_facility` `(string: "LOCAL0")` - Specifies the syslog facility to
write to. This has no effect unless `enable_syslog` is true.
- `tls` <code>([TLS][tls]: nil)</code> - Specifies configuration for TLS.
- `tls` `([TLS][tls]: nil)` - Specifies configuration for TLS.
- `vault` <code>([Vault][vault]: nil)</code> - Specifies configuration for
- `vault` `([Vault][vault]: nil)` - Specifies configuration for
connecting to Vault.
## Examples
Expand Down
75 changes: 75 additions & 0 deletions website/source/guides/install/windows-service.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
layout: "docs"
page_title: "Nomad as a Windows Service"
sidebar_current: "guides-install-windows-service"
description: |-
Discusses how to register and run Nomad as a native Windows service.
---

# Installing 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.

~> **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.
[`sc.exe`]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682107(v=vs.85).aspx
[logging]: /docs/configuration/index.html#log_file
4 changes: 4 additions & 0 deletions website/source/layouts/guides.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@

</ul>
</li>

<li<%= sidebar_current("guides-install-windows-service") %>>
<a href="/guides/install/windows-service.html">As a Windows Service</a>
</li>
</ul>
</li>

Expand Down

0 comments on commit 42c9b1d

Please sign in to comment.