Skip to content

Commit d4e6e73

Browse files
committed
cmd/scollector: remove fixEventMessageFile as it is not needed anymore
fixEventMessageFile may have been causing issues where the service didn't start within the 30s timeout that Windows enforces. Hopefully this will fix the Service Control Manager Event ID 7009 and 7000 errors that we are seeing.
1 parent edec5fd commit d4e6e73

File tree

1 file changed

+1
-31
lines changed

1 file changed

+1
-31
lines changed

cmd/scollector/service_windows.go

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
"bosun.org/_version"
1010
"bosun.org/slog"
11-
"golang.org/x/sys/windows/registry"
1211
"golang.org/x/sys/windows/svc"
1312
"golang.org/x/sys/windows/svc/debug"
1413
"golang.org/x/sys/windows/svc/eventlog"
@@ -136,7 +135,7 @@ func controlService(name string, c svc.Cmd, to svc.State) error {
136135
if err != nil {
137136
return fmt.Errorf("could not send control=%d: %v", c, err)
138137
}
139-
timeout := time.Now().Add(10 * time.Second)
138+
timeout := time.Now().Add(35 * time.Second)
140139
for status.State != to {
141140
if timeout.Before(time.Now()) {
142141
return fmt.Errorf("timeout waiting for service to go to state=%d", to)
@@ -172,11 +171,6 @@ loop:
172171
}
173172

174173
func runService(name string, isDebug bool) {
175-
errFix := fixEventMessageFile(name) //Temp fix. Remove after a few weeks.
176-
if errFix != nil {
177-
slog.Errorf("%s fixEventMessageFile failed: %v", name, errFix)
178-
return
179-
}
180174
if isDebug {
181175
slog.SetEventLog(debug.New(name), 1)
182176
} else {
@@ -200,27 +194,3 @@ func runService(name string, isDebug bool) {
200194
slog.Infof("%s service stopped", name)
201195
os.Exit(0)
202196
}
203-
204-
// This is a temporary method to fix an issue with the EventMessageFile.
205-
// See http://stackoverflow.com/questions/29130586 for details.
206-
func fixEventMessageFile(src string) error {
207-
const addKeyName = `SYSTEM\CurrentControlSet\Services\EventLog\Application`
208-
appkey, err := registry.OpenKey(registry.LOCAL_MACHINE, addKeyName, registry.ALL_ACCESS)
209-
if err != nil {
210-
return err
211-
}
212-
defer appkey.Close()
213-
sk, alreadyExist, err := registry.CreateKey(appkey, src, registry.ALL_ACCESS)
214-
if err != nil {
215-
return err
216-
}
217-
defer sk.Close()
218-
if alreadyExist {
219-
// Update REG_SZ key with expanded value for %systemroot% variable.
220-
err = sk.SetStringValue("EventMessageFile", os.ExpandEnv("${systemroot}\\System32\\EventCreate.exe"))
221-
if err != nil {
222-
return err
223-
}
224-
}
225-
return nil
226-
}

0 commit comments

Comments
 (0)