Skip to content

Commit

Permalink
Merge pull request #442 from lstocchi/noELService
Browse files Browse the repository at this point in the history
Warn user and keep executing if Event Log Service is stopped
  • Loading branch information
openshift-merge-bot[bot] authored Jan 8, 2025
2 parents 660f199 + cf01d72 commit 5f09250
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions cmd/win-sshproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package main

import (
"context"
"errors"
"fmt"
"net/url"
"os"
Expand All @@ -24,8 +25,9 @@ import (
)

const (
ERR_BAD_ARGS = 0x000A
WM_QUIT = 0x12
ERR_BAD_ARGS = 0x000A
WM_QUIT = 0x12
RPC_S_SERVER_UNAVAILABLE syscall.Errno = 1722
)

var (
Expand Down Expand Up @@ -54,11 +56,23 @@ func main() {
os.Exit(ERR_BAD_ARGS)
}

// Attempt to set up logging with the event log service.
// If it fails because the Windows Event Log Service is not running, show a warning
// and continue execution. There could be a reason why user disabled the Event Log.
log, err := setupLogging(args[0])
if err != nil {
os.Exit(1)
if errors.Is(err, syscall.Errno(RPC_S_SERVER_UNAVAILABLE)) {
logrus.Warn("RPC server is unavailable, continuing without event log")
} else {
logrus.Errorf("Error setting up logging: %v", err)
os.Exit(1)
}
}

// Defer closing the log if setup was successful
if log != nil {
defer log.Close()
}
defer log.Close()

stateDir = args[1]

Expand Down

0 comments on commit 5f09250

Please sign in to comment.