Skip to content

Commit

Permalink
Upgrade glog depdendency
Browse files Browse the repository at this point in the history
This allows us to get rid of the workarounds for stderr being unavailable when running as a windows service.

Compare: https://github.com/golang/glog/releases/tag/v1.2.3
PiperOrigin-RevId: 694432401
  • Loading branch information
torsm authored and copybara-github committed Nov 8, 2024
1 parent 94a0688 commit c7412e8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
13 changes: 0 additions & 13 deletions fleetspeak/src/client/entry/entry_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func (m *fleetspeakService) Execute(args []string, r <-chan svc.ChangeRequest, c
const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown | svc.AcceptParamChange
changes <- svc.Status{State: svc.StartPending}
changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted}
tryDisableStderr()
log.Info("Service started.")

ctx, cancel := context.WithCancel(context.Background())
Expand Down Expand Up @@ -120,15 +119,3 @@ func RunMain(innerMain InnerMain, windowsServiceName string) {
func ExitUngracefully(cause error) {
log.Exitf("Exiting ungracefully due to %v", cause)
}

// tryDisableStderr redirects [os.Stderr] to [os.DevNull]. When running as a
// Windows service, stderr is not available, causing the logging library to
// crash when attempting to write an error log.
func tryDisableStderr() {
devNull, err := os.OpenFile(os.DevNull, os.O_WRONLY, 0)
if err != nil {
log.Warningf("Failed to disable stderr while running as a Windows service, the application might spontaneously shut down ungracefully: %v", err)
return
}
os.Stderr = devNull
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
cloud.google.com/go/pubsub v1.38.0
github.com/Microsoft/go-winio v0.6.1
github.com/go-sql-driver/mysql v1.6.0
github.com/golang/glog v1.2.0
github.com/golang/glog v1.2.3
github.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95
github.com/mattn/go-sqlite3 v1.14.16
github.com/pires/go-proxyproto v0.6.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68=
github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
github.com/golang/glog v1.2.3 h1:oDTdz9f5VGVVNGu/Q7UXKWYsD0873HXLHdJUNBsSEKM=
github.com/golang/glog v1.2.3/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down

0 comments on commit c7412e8

Please sign in to comment.