-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows Service #1543
Windows Service #1543
Conversation
Updated the windows dependencies so that the versions matched the dependencies for Mac OS and Linux. Additionally added some that were complained about being missing at compile time.
Incorporated the library github.com/kardianos/service to manage the service on the various platforms (including Windows). This required an alternate main function. The original main function was renamed to reloadLoop (as that is what the main loop in it does) (it also got a couple of parameters). The service management library calls it as the main body of the program.
Due to compilation issues on Windows, moved the code from service.go into telegraf.go and removed service.go entirely.
Updated the dependencies so that it builds properly on Windows, additionally, fixed the registered command for starting it as a service (needed to add the config file option). This currently standardizes it as a C:\telegraf\telegraf.conf on Windows.
Removed all the common dependencies from the Godeps_windows file and modified Makefile to load Godeps and then Godeps_windows when building for Windows. This should reduce problems caused by the Godeps_windows file being forgotten when updating dependencies.
type program struct{} | ||
|
||
func reloadLoop(stop chan struct{}, s service.Service) { | ||
defer func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain what this does? (the defer
function and service.Interactive()
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
service.Interactive()
is a boolean function which detects if the program is being run interactively (as opposed to as a service). The purpose of the defer
function is to cause the program to exit when the main function does if it is being run interactively. It was added in response to a bug where the program would never exit if you simply asked it to provide information (ie telegraf -help
).
thanks @butitsnotme! |
The service library [kardianos/service](github.com/kardianos/service) has been disabled on all platforms but windows, as there is already existing infrastructure for other platforms.
excellent, can you also edit this document: https://github.com/influxdata/telegraf/blob/master/docs/WINDOWS_SERVICE.md to reflect the changes? I believe now we only need to do a |
@butitsnotme I haven't been able to get this running properly. The "telegraf -service install" works but then I can't get it to start via This is on Windows Server 2012 |
It appears that gdm accidentally added the project itself to the dependency list. This caused the dependency restoration to select an earlier version of the project during build. This only affected windows. This only affected builds after 020b2c7
@sparrc This happened because the start command was wrong, it didn't have the config file in it. The regression occurred because in commit 020b2c7 the telegraf repository itself got added as a dependency, causing the code base to be rolled back during compile. I have removed the dependency manually, however there may be a bug with gdm... The latest commit should compile and run (I just tested it against a clean GO directory and it is running on Windows 8.1 now) |
Removed the documentation about using NSSM and added documentation on installing telegraf directly as a Windows Service.
Added the license information for github.com/kardianos/service which is licensed under the ZLib license, although that name is never mentioned the license text matches word for word.
@@ -45,6 +47,8 @@ var fOutputFiltersLegacy = flag.String("outputfilter", "", | |||
"filter the outputs to enable, separator is :") | |||
var fConfigDirectoryLegacy = flag.String("configdirectory", "", | |||
"directory containing additional *.conf files") | |||
var fService = flag.String("service", "", | |||
"operate on the service") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should also be in a if windows {}
conditional (or equivalent behavior). Otherwise we have this flag which will be present, but does nothing on other OSs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'll still show up in the --help
output though. I would just leave it and put in a (windows only)
blurb in the doc.
@butitsnotme should we change the default install location to |
Updated the default location of the configuration file on Windows from C:\telegraf\telegraf.conf to C:\Program Files\Telegraf\telegraf.conf. With this change includes updating the directions, including directing that the executable be put into that same directory. Additionally, as noted in the instructions, the location of the config file for the service may be changed by specifying the location with the `-config` flag at install time.
svcConfig service.Config => svcConfig *service.Config (It needed to be a pointer)
Nice work @butitsnotme . Installation location |
like to see this in the v1.0 milestone. |
this will now be the default config file location on windows, basically it is the windows equivalent of /etc/telegraf/telegraf.conf also updating the changelog closes #1543
this will now be the default config file location on windows, basically it is the windows equivalent of /etc/telegraf/telegraf.conf also updating the changelog closes #1543
this will now be the default config file location on windows, basically it is the windows equivalent of /etc/telegraf/telegraf.conf also updating the changelog closes #1543
this will now be the default config file location on windows, basically it is the windows equivalent of /etc/telegraf/telegraf.conf also updating the changelog closes #1543
thank you very much @butitsnotme! |
this will now be the default config file location on windows, basically it is the windows equivalent of /etc/telegraf/telegraf.conf also updating the changelog closes influxdata#1543
Windows Service
This pull requests adds the capability for Telegraf to run as a Windows service. This is accomplished by integrating the library kardianos/service. This, once accepted, should close issue #860.
Brief summary of changes
reloadLoop
Required for all PRs: