Skip to content

Commit

Permalink
feat(packaging/windows): specify agent restart when getting failure o…
Browse files Browse the repository at this point in the history
…n Windows (grafana#5833)

* feat(packaging/windows): specify agent restart when getting failure on Windows

Signed-off-by: hainenber <[email protected]>
  • Loading branch information
hainenber committed Nov 25, 2023
1 parent b097057 commit a2654f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Main (unreleased)
`prometheus.exporter.cadvisor` (flow mode) and the `cadvisor` integration
(static mode). (@hainenber)

- Grafana Agent on Windows now automatically restarts on failure. (@hainenber)

### Bugfixes

- Permit `X-Faro-Session-ID` header in CORS requests for the `faro.receiver`
Expand Down
4 changes: 4 additions & 0 deletions packaging/grafana-agent-flow/windows/install_script.nsis
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ Section "install"
# Start the service.
nsExec::ExecToLog 'sc start "Grafana Agent Flow"'
Pop $0

# Auto-restart agent on failure. Reset failure counter after 60 seconds without failure
nsExec::ExecToLog `sc failure "Grafana Agent Flow" reset= 60 actions= restart/5000 reboot= "Grafana Agent Flow has failed. Restarting in 5 seconds"`
Pop $0
SectionEnd

Function CreateConfig
Expand Down
3 changes: 3 additions & 0 deletions packaging/grafana-agent/windows/install_script.nsis
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ Function Install
Pop $0
nsExec::ExecToLog `sc start "Grafana Agent"`
Pop $0
# Auto-restart agent on failure. Reset failure counter after 60 seconds without failure
nsExec::ExecToLog `sc failure "Grafana Agent" reset= 60 actions= restart/5000 reboot= "Grafana Agent has failed. Restarting in 5 seconds"`
Pop $0
FunctionEnd

Function WriteConfig
Expand Down

0 comments on commit a2654f8

Please sign in to comment.