From cd038191f683235551871c619f61290c4bdefedf Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 13 Mar 2018 04:14:07 +0100 Subject: [PATCH] Time values can also be time spans in string format --- createcmd.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/createcmd.go b/createcmd.go index 80757c5..be5172d 100644 --- a/createcmd.go +++ b/createcmd.go @@ -5,7 +5,6 @@ import ( "io/ioutil" "os" "path/filepath" - "strconv" "strings" "github.com/coreos/go-systemd/unit" @@ -30,9 +29,9 @@ type CreateOptions struct { Group string Restart string - RestartSec uint64 - TimeoutStartSec uint64 - TimeoutStopSec uint64 + RestartSec string + TimeoutStartSec string + TimeoutStopSec string After string WantedBy string @@ -183,9 +182,9 @@ func executeCreate() error { &unit.UnitOption{"Service", "User", createOpts.User}, &unit.UnitOption{"Service", "Group", createOpts.Group}, &unit.UnitOption{"Service", "Restart", createOpts.Restart}, - &unit.UnitOption{"Service", "RestartSec", strconv.FormatUint(createOpts.RestartSec, 10)}, - &unit.UnitOption{"Service", "TimeoutStartSec", strconv.FormatUint(createOpts.TimeoutStartSec, 10)}, - &unit.UnitOption{"Service", "TimeoutStopSec", strconv.FormatUint(createOpts.TimeoutStopSec, 10)}, + &unit.UnitOption{"Service", "RestartSec", createOpts.RestartSec}, + &unit.UnitOption{"Service", "TimeoutStartSec", createOpts.TimeoutStartSec}, + &unit.UnitOption{"Service", "TimeoutStopSec", createOpts.TimeoutStopSec}, &unit.UnitOption{"Install", "WantedBy", createOpts.WantedBy}, } @@ -227,9 +226,9 @@ func init() { createCmd.PersistentFlags().StringVarP(&createOpts.Group, "group", "g", "root", "Group to run service as") createCmd.PersistentFlags().StringVarP(&createOpts.Restart, "restart", "r", "on-failure", "When to restart (no, always, on-success, on-failure, on-abnormal, on-abort or on-watchdog)") - createCmd.PersistentFlags().Uint64VarP(&createOpts.RestartSec, "restartsec", "s", 5, "How many seconds between restarts") - createCmd.PersistentFlags().Uint64Var(&createOpts.TimeoutStartSec, "timeoutstartsec", 0, "How many seconds to wait for a startup") - createCmd.PersistentFlags().Uint64Var(&createOpts.TimeoutStopSec, "timeoutstopsec", 0, "How many seconds to wait when stoping a service") + createCmd.PersistentFlags().StringVarP(&createOpts.RestartSec, "restartsec", "s", "", "How many seconds between restarts") + createCmd.PersistentFlags().StringVar(&createOpts.TimeoutStartSec, "timeoutstartsec", "", "How many seconds to wait for a startup") + createCmd.PersistentFlags().StringVar(&createOpts.TimeoutStopSec, "timeoutstopsec", "", "How many seconds to wait when stoping a service") createCmd.PersistentFlags().StringVarP(&createOpts.After, "after", "a", "", "Target after which the service will be started") createCmd.PersistentFlags().StringVarP(&createOpts.WantedBy, "wantedby", "b", "", "This service is wanted by this target")