mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
✨ Add status command to check service state
Introduced a new `status` command to display the service state (running, stopped, or unknown). Improved user feedback by logging the status and handling potential errors during the status check.
This commit is contained in:
@@ -206,7 +206,19 @@ func main() {
|
||||
// add help command
|
||||
case "help":
|
||||
fmt.Println("Usage: oneuptime-infrastructure-agent configure | uninstall | start | stop | restart")
|
||||
|
||||
case "status":
|
||||
s, err := s.Status()
|
||||
if err != nil {
|
||||
slog.Error(err.Error())
|
||||
os.Exit(2)
|
||||
}
|
||||
if s == service.StatusRunning {
|
||||
slog.Info("Service is running")
|
||||
} else if s == service.StatusStopped {
|
||||
slog.Info("Service is stopped")
|
||||
} else {
|
||||
slog.Info("Service status unknown")
|
||||
}
|
||||
default:
|
||||
slog.Error("Invalid command")
|
||||
os.Exit(2)
|
||||
|
||||
Reference in New Issue
Block a user