From 32e06a489ddbaac11d4b5f2d98af67d41a804da8 Mon Sep 17 00:00:00 2001
From: Pierre Fersing <pierref@pierref.org>
Date: Wed, 1 Feb 2017 15:12:35 +0100
Subject: [PATCH] Keep -config-directory when running as Windows service
 (#2330)

* Keep -config-directory when running as Windows service

* Update changelog
---
 CHANGELOG.md             | 2 +-
 cmd/telegraf/telegraf.go | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8e5865e7..5131f50e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,10 +11,10 @@ It is highly recommended that all users migrate to the new riemann output plugin
 
 ### Features
 
-- [#2141](https://github.com/influxdata/telegraf/pull/2141): Logparser handles newly-created files.
 - [#2137](https://github.com/influxdata/telegraf/pull/2137): Added userstats to mysql input plugin.
 - [#2179](https://github.com/influxdata/telegraf/pull/2179): Added more InnoDB metric to MySQL plugin.
 - [#2251](https://github.com/influxdata/telegraf/pull/2251): InfluxDB output: use own client for improved through-put and less allocations.
+- [#2330](https://github.com/influxdata/telegraf/pull/2330): Keep -config-directory when running as Windows service.
 - [#1900](https://github.com/influxdata/telegraf/pull/1900): Riemann plugin rewrite.
 - [#1453](https://github.com/influxdata/telegraf/pull/1453): diskio: add support for name templates and udev tags.
 - [#2277](https://github.com/influxdata/telegraf/pull/2277): add integer metrics for Consul check health state.
diff --git a/cmd/telegraf/telegraf.go b/cmd/telegraf/telegraf.go
index 0f94c6e2..398617e0 100644
--- a/cmd/telegraf/telegraf.go
+++ b/cmd/telegraf/telegraf.go
@@ -327,6 +327,9 @@ func main() {
 			if *fConfig != "" {
 				(*svcConfig).Arguments = []string{"-config", *fConfig}
 			}
+			if *fConfigDirectory != "" {
+				(*svcConfig).Arguments = append((*svcConfig).Arguments, "-config-directory", *fConfigDirectory)
+			}
 			err := service.Control(s, *fService)
 			if err != nil {
 				log.Fatal("E! " + err.Error())
-- 
GitLab