add IsRunning helper

This commit is contained in:
Tai Groot
2023-06-20 23:49:23 -04:00
parent c9e7f79f8c
commit a82f845b84

View File

@@ -97,3 +97,10 @@ func IsMasked(ctx context.Context, unit string, opts Options) (bool, error) {
}
return false, nil
}
// check if a service is running
// https://unix.stackexchange.com/a/396633
func IsRunning(ctx context.Context, unit string, opts Options) (bool, error) {
status, err := Show(ctx, unit, properties.SubState, opts)
return status == "running", err
}