func createEventMonitor(control *gonit.Control, configManager *gonit.ConfigManager) { eventMonitor = &gonit.EventMonitor{} err := eventMonitor.Start(configManager, control) if err != nil { log.Fatal(err) } control.RegisterEventMonitor(eventMonitor) }
func runDaemon(control *gonit.Control, configManager *gonit.ConfigManager) { daemon := settings.Daemon if daemon.IsRunning() { log.Fatalf("%s daemon is already running", daemon.Name) } if !foreground { log.Print("daemonize - not yet supported") } if err := control.LoadPersistState(); err != nil { log.Fatal(err) } err := daemon.SavePid(os.Getpid()) if err != nil { log.Fatal(err) } defer os.Remove(daemon.Pidfile) watcher = &gonit.Watcher{Control: control} createEventMonitor(control, configManager) start() loop() }