From a9afd2f030733bcb018b413de485cb98d149f310 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Wed, 4 Apr 2018 16:29:42 -0700 Subject: [PATCH] Add config-directory documentation for Windows service --- cmd/telegraf/telegraf.go | 8 ++++---- docs/WINDOWS_SERVICE.md | 12 ++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cmd/telegraf/telegraf.go b/cmd/telegraf/telegraf.go index e13683fc4..c02dce88b 100644 --- a/cmd/telegraf/telegraf.go +++ b/cmd/telegraf/telegraf.go @@ -365,7 +365,7 @@ func main() { DisplayName: "Telegraf Data Collector Service", Description: "Collects data using a series of plugins and publishes it to" + "another series of plugins.", - Arguments: []string{"-config", "C:\\Program Files\\Telegraf\\telegraf.conf"}, + Arguments: []string{"--config", "C:\\Program Files\\Telegraf\\telegraf.conf"}, } prg := &program{ @@ -378,14 +378,14 @@ func main() { if err != nil { log.Fatal("E! " + err.Error()) } - // Handle the -service flag here to prevent any issues with tooling that + // Handle the --service flag here to prevent any issues with tooling that // may not have an interactive session, e.g. installing from Ansible. if *fService != "" { if *fConfig != "" { - (*svcConfig).Arguments = []string{"-config", *fConfig} + (*svcConfig).Arguments = []string{"--config", *fConfig} } if *fConfigDirectory != "" { - (*svcConfig).Arguments = append((*svcConfig).Arguments, "-config-directory", *fConfigDirectory) + (*svcConfig).Arguments = append((*svcConfig).Arguments, "--config-directory", *fConfigDirectory) } err := service.Control(s, *fService) if err != nil { diff --git a/docs/WINDOWS_SERVICE.md b/docs/WINDOWS_SERVICE.md index 2b4d4f0e2..886887d52 100644 --- a/docs/WINDOWS_SERVICE.md +++ b/docs/WINDOWS_SERVICE.md @@ -5,7 +5,7 @@ the general steps to set it up. 1. Obtain the telegraf windows distribution 2. Create the directory `C:\Program Files\Telegraf` (if you install in a different - location simply specify the `-config` parameter with the desired location) + location simply specify the `--config` parameter with the desired location) 3. Place the telegraf.exe and the telegraf.conf config file into `C:\Program Files\Telegraf` 4. To install the service into the Windows Service Manager, run the following in PowerShell as an administrator (If necessary, you can wrap any spaces in the file paths in double quotes ""): @@ -26,6 +26,15 @@ the general steps to set it up. > net start telegraf ``` +## Config Directory + +You can also specify a `--config-directory` for the service to use: +1. Create a directory for config snippets: `C:\Program Files\Telegraf\telegraf.d` +2. Include the `--config-directory` option when registering the service: + ``` + > C:\"Program Files"\Telegraf\telegraf.exe --service install --config C:\"Program Files"\Telegraf\telegraf.conf --config-directory C:\"Program Files"\Telegraf\telegraf.d + ``` + ## Other supported operations Telegraf can manage its own service through the --service flag: @@ -37,7 +46,6 @@ Telegraf can manage its own service through the --service flag: | `telegraf.exe --service start` | Start the telegraf service | | `telegraf.exe --service stop` | Stop the telegraf service | - Troubleshooting common error #1067 When installing as service in Windows, always double check to specify full path of the config file, otherwise windows service will fail to start