This document intended to cover some basic problems, which generally users face while starting Nomad as Windows Services. This article will cover those problems with their verified solutions.
As you know, you can configure Nomad on Windows Operating System as well. You can configure Nomad Open Source or Enterprise version as a Windows service. And you can use any one of two methods:
- PowerShell: (New-Service)
- SC: (sc.exe)
Both the above method are best suitable for creating Nomad as Windows service. You can use below official URL from HashiCorp website for steps and commands:
URL - https://learn.hashicorp.com/tutorials/nomad/windows-agent?in=nomad/windows
After installation and configuration of Nomad as a Windows Service, we need to start the Nomad Service. While starting Nomad service, we will face a basic problem like "data_dir" is not able to pick absolute windows path. This can be happen due to two reasons which are listed below.
Problem 1 - Due to incorrect Windows path for data_dir parameter.
Example - Here is one sample nomad.hcl file -
datacenter = "dc1"
server {
client { |
While starting my nomad service with above nomad configuration file, I received below error -
Here in above nomad configuration file, data_dir value is not an absolute path. It is in incorrect way and that is why nomad.exe file is throwing error (As per above snippet).
Solution - For this, you can give path like - "C:\WorkSpace\Nomad\data".
But with this path there is one more problem which has been described in below problem 2.
Problem 2 - data_dir path is correct, but there is an issue with the directory separator character not being interpreted properly.
Example - Here is one sample nomad.hcl file -
datacenter = "dc1"
server {
client { |
While starting my nomad service with above nomad configuration file, I received below error -
Here in above nomad configuration file, absolute path is given for data_dir parameter but slash (\) symbol is not properly escaped and nomad.exe file not able to pick the path correctly and showing the error "illegal char escape". (As mentioned in above error snippet).
Solution - For solving this, you can use absolute path as below -
"C:\\WorkSpace\\Nomad\\data"
Here, one more slash (\) is being used because this additional slash(\) is being used as an escape character.
Please note some below points -
- Above article is for all Nomad versions (open source and enterprise both) which are released till date by HashiCorp.
- All above configuration files example and path examples are as per my environment. You can change/define this as per your environment configuration.
- Above problems have been tested successfully on all versions of Microsoft Windows Operating System till 2019 edition.
Resources -
Releases of Nomad - https://releases.hashicorp.com/nomad/
Nomad Official Page - https://www.nomadproject.io/