Add ability to define a custom service name when installing as a Windows service (#4753)
This commit is contained in:
parent
008ee617cb
commit
6b7d64f1d6
|
@ -55,6 +55,7 @@ var fUsage = flag.String("usage", "",
|
||||||
"print usage for a plugin, ie, 'telegraf --usage mysql'")
|
"print usage for a plugin, ie, 'telegraf --usage mysql'")
|
||||||
var fService = flag.String("service", "",
|
var fService = flag.String("service", "",
|
||||||
"operate on the service (windows only)")
|
"operate on the service (windows only)")
|
||||||
|
var fServiceName = flag.String("service-name", "telegraf", "service name (windows only)")
|
||||||
var fRunAsConsole = flag.Bool("console", false, "run as console application (windows only)")
|
var fRunAsConsole = flag.Bool("console", false, "run as console application (windows only)")
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -327,7 +328,7 @@ func main() {
|
||||||
|
|
||||||
if runtime.GOOS == "windows" && !(*fRunAsConsole) {
|
if runtime.GOOS == "windows" && !(*fRunAsConsole) {
|
||||||
svcConfig := &service.Config{
|
svcConfig := &service.Config{
|
||||||
Name: "telegraf",
|
Name: *fServiceName,
|
||||||
DisplayName: "Telegraf Data Collector Service",
|
DisplayName: "Telegraf Data Collector Service",
|
||||||
Description: "Collects data using a series of plugins and publishes it to" +
|
Description: "Collects data using a series of plugins and publishes it to" +
|
||||||
"another series of plugins.",
|
"another series of plugins.",
|
||||||
|
|
|
@ -46,6 +46,16 @@ Telegraf can manage its own service through the --service flag:
|
||||||
| `telegraf.exe --service start` | Start the telegraf service |
|
| `telegraf.exe --service start` | Start the telegraf service |
|
||||||
| `telegraf.exe --service stop` | Stop the telegraf service |
|
| `telegraf.exe --service stop` | Stop the telegraf service |
|
||||||
|
|
||||||
|
## Install multiple services
|
||||||
|
|
||||||
|
You can install multiple telegraf instances with --service-name flag:
|
||||||
|
|
||||||
|
```
|
||||||
|
> C:\"Program Files"\Telegraf\telegraf.exe --service install --service-name telegraf-1
|
||||||
|
> C:\"Program Files"\Telegraf\telegraf.exe --service install --service-name telegraf-2
|
||||||
|
> C:\"Program Files"\Telegraf\telegraf.exe --service uninstall --service-name telegraf-1
|
||||||
|
```
|
||||||
|
|
||||||
Troubleshooting common error #1067
|
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
|
When installing as service in Windows, always double check to specify full path of the config file, otherwise windows service will fail to start
|
||||||
|
|
|
@ -33,6 +33,7 @@ The commands & flags are:
|
||||||
|
|
||||||
--console run as console application (windows only)
|
--console run as console application (windows only)
|
||||||
--service <service> operate on the service (windows only)
|
--service <service> operate on the service (windows only)
|
||||||
|
--service-name service name (windows only)
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
|
@ -59,4 +60,7 @@ Examples:
|
||||||
|
|
||||||
# install telegraf service
|
# install telegraf service
|
||||||
telegraf --service install --config "C:\Program Files\Telegraf\telegraf.conf"
|
telegraf --service install --config "C:\Program Files\Telegraf\telegraf.conf"
|
||||||
|
|
||||||
|
# install telegraf service with custom name
|
||||||
|
telegraf --service install --service-name=my-telegraf
|
||||||
`
|
`
|
||||||
|
|
Loading…
Reference in New Issue