github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/install/windows-service.mdx (about) 1 --- 2 layout: docs 3 page_title: Nomad as a Windows Service 4 description: Discusses how to register and run Nomad as a native Windows service. 5 --- 6 7 # Installing Nomad as a Windows service 8 9 Nomad can be run as a native Windows service. In order to do this, you will need 10 to register the Nomad application with the Windows Service Control Manager using 11 [`sc.exe`], configure Nomad to log to a file, and then start the Nomad service. 12 13 ~> **Note:** These steps should be run in a PowerShell session with Administrator 14 capabilities. 15 16 ## Register Nomad with Windows 17 18 [Download] the Nomad binary for your architecture. 19 20 Use the [`sc.exe`] command to create a Service named "Nomad". The binPath 21 argument should include the fully qualified path to the Nomad executable and any 22 arguments to the nomad command: agent, -config, etc. 23 24 ```plaintext 25 sc.exe create "Nomad" binPath="«full path to nomad.exe» agent -config=«path to config file or directory»" start= auto 26 [SC] CreateService SUCCESS 27 ``` 28 29 If you receive a success message, your service is registered with the service 30 manager. 31 32 If you get an error, please verify the path to the binary and check the 33 arguments, by running the contents of `binPath` directly in a PowerShell session 34 and observing the results. 35 36 ## Configure Nomad to log to file 37 38 Because Windows services run non-interactively and Nomad does not log to the 39 Windows Event Viewer, you will need to configure file-based logging in Nomad. 40 41 To do this, set the [`log_file`][logging] argument in your Nomad configuration 42 file or in the binPath argument of the [`sc.exe`] command used to register the 43 service. 44 45 ## Start the Nomad service 46 47 You have two ways to start the service. 48 49 - Go to the Windows Service Manager, and look for **Nomad** in the service name 50 column. Click the _Start_ button to start the service. 51 52 - Using the [`sc.exe`] command: 53 54 ```plaintext 55 sc.exe start "Nomad" 56 57 SERVICE_NAME: Nomad 58 TYPE : 10 WIN32_OWN_PROCESS 59 STATE : 4 RUNNING 60 (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN) 61 WIN32_EXIT_CODE : 0 (0x0) 62 SERVICE_EXIT_CODE : 0 (0x0) 63 CHECKPOINT : 0x0 64 WAIT_HINT : 0x0 65 PID : 8008 66 FLAGS : 67 ``` 68 69 The service automatically starts up during/after boot, so you don't need to 70 launch Nomad from the command-line again. 71 72 [`sc.exe`]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682107(v=vs.85).aspx 73 [download]: /downloads 74 [logging]: /docs/configuration#log_file