mirror of
https://github.com/taigrr/systemctl.git
synced 2026-04-02 02:28:50 -07:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
4e38d03629
|
|||
|
701893ebbd
|
@@ -15,11 +15,11 @@ func GetStartTime(ctx context.Context, unit string, opts Options) (time.Time, er
|
||||
value, err := Show(ctx, unit, properties.ExecMainStartTimestamp, opts)
|
||||
|
||||
if err != nil {
|
||||
return time.Unix(0, 0), err
|
||||
return time.Time{}, err
|
||||
}
|
||||
// ExecMainStartTimestamp returns an empty string if the unit is not running
|
||||
if value == "" {
|
||||
return time.Unix(0, 0), ErrUnitNotActive
|
||||
return time.Time{}, ErrUnitNotActive
|
||||
}
|
||||
return time.Parse(dateFormat, value)
|
||||
}
|
||||
|
||||
8
util.go
8
util.go
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
)
|
||||
@@ -15,7 +16,9 @@ const killed = 130
|
||||
func init() {
|
||||
path, err := exec.LookPath("systemctl")
|
||||
if err != nil {
|
||||
panic(ErrNotInstalled)
|
||||
log.Printf("%v", ErrNotInstalled)
|
||||
systemctl = ""
|
||||
return
|
||||
}
|
||||
systemctl = path
|
||||
}
|
||||
@@ -30,6 +33,9 @@ func execute(ctx context.Context, args []string) (string, string, int, error) {
|
||||
warnings string
|
||||
)
|
||||
|
||||
if systemctl == "" {
|
||||
panic(ErrNotInstalled)
|
||||
}
|
||||
cmd := exec.CommandContext(ctx, systemctl, args...)
|
||||
cmd.Stdout = &stdout
|
||||
cmd.Stderr = &stderr
|
||||
|
||||
Reference in New Issue
Block a user