mirror of
https://github.com/fosrl/olm.git
synced 2026-02-08 05:56:41 +00:00
7
main.go
7
main.go
@@ -87,6 +87,13 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
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":
|
||||
fmt.Println("Olm WireGuard VPN Client")
|
||||
fmt.Println("\nWindows Service Management:")
|
||||
|
||||
@@ -44,3 +44,7 @@ func runService(name string, isDebug bool, args []string) {
|
||||
func setupWindowsEventLog() {
|
||||
// No-op on non-Windows platforms
|
||||
}
|
||||
|
||||
func watchLogFile(end bool) error {
|
||||
return fmt.Errorf("watching log file is only available on Windows")
|
||||
}
|
||||
|
||||
@@ -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("Log file: %s\n", logFile)
|
||||
|
||||
// Start the service
|
||||
err := startService([]string{}) // Pass empty args since we already saved them
|
||||
@@ -390,10 +385,12 @@ func debugService(args []string) error {
|
||||
fmt.Printf("================================================================================\n")
|
||||
|
||||
// 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
|
||||
file, err := os.Open(logPath)
|
||||
if err != nil {
|
||||
@@ -422,8 +419,10 @@ func watchLogFile(logPath string) error {
|
||||
case <-sigCh:
|
||||
fmt.Printf("\n\nStopping log watch...\n")
|
||||
// stop the service if needed
|
||||
if err := stopService(); err != nil {
|
||||
fmt.Printf("Failed to stop service: %v\n", err)
|
||||
if end {
|
||||
if err := stopService(); err != nil {
|
||||
fmt.Printf("Failed to stop service: %v\n", err)
|
||||
}
|
||||
}
|
||||
fmt.Printf("Log watch stopped.\n")
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user