Skip to content
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

chore(windows): Rework Windows service handling #15372

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

srebhan
Copy link
Contributor

@srebhan srebhan commented May 16, 2024

Summary

This PR reworked the Windows service handling of Telegraf, including the replacing a 3rd-party library with standard calls as well as introducing the service command instead of the --service flag.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #14834

@telegraf-tiger telegraf-tiger bot added the chore label May 16, 2024
@Hr0bar
Copy link
Contributor

Hr0bar commented May 17, 2024

Will this be an important/breaking changelog change? As the --service to service will likely break deploy scripts/pipelines

@srebhan
Copy link
Contributor Author

srebhan commented May 17, 2024

@Hr0bar of course --service will still work ;-), but it is marked as deprecated and will show a message suggesting to switch to the service command.

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label May 22, 2024
@srebhan srebhan assigned powersj and DStrand1 and unassigned srebhan May 22, 2024
Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the (what looks like) backwards compatible commands and the cleanup of reading the config.

Played with this locally a bit and looked good. I think we should clean up the service subcommand output a bit, no need to echo what we are going to do back to the user, and there always appears to be an extra newline?

cmd/telegraf/cmd_win_service.go Show resolved Hide resolved
`,
Action: func(cCtx *cli.Context) error {
name := cCtx.String("service-name")
fmt.Fprintf(outputBuffer, "Querying status of service %s...\n", name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove these as the user should know what they are doing if they run the subcommand status.

cmd/telegraf/cmd_win_service.go Show resolved Hide resolved
`,
Action: func(cCtx *cli.Context) error {
name := cCtx.String("service-name")
fmt.Fprintf(outputBuffer, "Stopping service %s...\n", name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove, don't need to repeat what the user told us to do.

cmd/telegraf/cmd_win_service.go Show resolved Hide resolved
cmd/telegraf/cmd_win_service.go Show resolved Hide resolved
cmd/telegraf/cmd_win_service.go Show resolved Hide resolved
`,
Action: func(cCtx *cli.Context) error {
name := cCtx.String("service-name")
fmt.Fprintf(outputBuffer, "Uninstalling service %s...\n", name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

configDirs: cCtx.StringSlice("config-directory"),
}
name := cCtx.String("service-name")
fmt.Fprintf(outputBuffer, "Installing service %s...\n", name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

cmd/telegraf/cmd_win_service.go Show resolved Hide resolved
@telegraf-tiger
Copy link
Contributor

`,
Action: func(cCtx *cli.Context) error {
name := cCtx.String("service-name")
fmt.Fprintf(outputBuffer, "Starting service %s...\n", name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fmt.Fprintf(outputBuffer, "Starting service %s...\n", name)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srebhan can we get rid of this one and call it good?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/agent chore platform/windows ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect telegraf service termination during operating system reboot
4 participants