Service working?

Former-commit-id: 7802248085
This commit is contained in:
Owen
2025-07-24 11:06:53 -07:00
parent 25a9b83496
commit 8d72e77d57
3 changed files with 19 additions and 9 deletions

View File

@@ -87,6 +87,13 @@ func main() {
os.Exit(1) os.Exit(1)
} }
return return
case "logs":
err := watchLogFile(false)
if err != nil {
fmt.Printf("Failed to watch log file: %v\n", err)
os.Exit(1)
}
return
case "help", "--help", "-h": case "help", "--help", "-h":
fmt.Println("Olm WireGuard VPN Client") fmt.Println("Olm WireGuard VPN Client")
fmt.Println("\nWindows Service Management:") fmt.Println("\nWindows Service Management:")

View File

@@ -44,3 +44,7 @@ func runService(name string, isDebug bool, args []string) {
func setupWindowsEventLog() { func setupWindowsEventLog() {
// No-op on non-Windows platforms // No-op on non-Windows platforms
} }
func watchLogFile(end bool) error {
return fmt.Errorf("watching log file is only available on Windows")
}

View File

@@ -373,12 +373,7 @@ func debugService(args []string) error {
} }
} }
// Get the log file path
logDir := filepath.Join(os.Getenv("PROGRAMDATA"), "Olm", "logs")
logFile := filepath.Join(logDir, "olm.log")
fmt.Printf("Starting service in debug mode...\n") fmt.Printf("Starting service in debug mode...\n")
fmt.Printf("Log file: %s\n", logFile)
// Start the service // Start the service
err := startService([]string{}) // Pass empty args since we already saved them err := startService([]string{}) // Pass empty args since we already saved them
@@ -390,10 +385,12 @@ func debugService(args []string) error {
fmt.Printf("================================================================================\n") fmt.Printf("================================================================================\n")
// Watch the log file // Watch the log file
return watchLogFile(logFile) return watchLogFile(true)
} }
func watchLogFile(logPath string) error { func watchLogFile(end bool) error {
logDir := filepath.Join(os.Getenv("PROGRAMDATA"), "Olm", "logs")
logPath := filepath.Join(logDir, "olm.log")
// Open the log file // Open the log file
file, err := os.Open(logPath) file, err := os.Open(logPath)
if err != nil { if err != nil {
@@ -422,8 +419,10 @@ func watchLogFile(logPath string) error {
case <-sigCh: case <-sigCh:
fmt.Printf("\n\nStopping log watch...\n") fmt.Printf("\n\nStopping log watch...\n")
// stop the service if needed // stop the service if needed
if err := stopService(); err != nil { if end {
fmt.Printf("Failed to stop service: %v\n", err) if err := stopService(); err != nil {
fmt.Printf("Failed to stop service: %v\n", err)
}
} }
fmt.Printf("Log watch stopped.\n") fmt.Printf("Log watch stopped.\n")
return nil return nil