From: Sergey Matveev Date: Fri, 15 Oct 2021 09:27:26 +0000 (+0300) Subject: timeout utility replaces -max-secs X-Git-Tag: v2.0.0~10 X-Git-Url: http://www.git.stargrave.org/?p=paster.git;a=commitdiff_plain;h=8bc46fea362cef7900632a9587d8f5f540e5976e;hp=d67f119d3cd963f263a90985f9d5a254c4618791 timeout utility replaces -max-secs --- diff --git a/INSTALL b/INSTALL index 5317220..28a9b0b 100644 --- a/INSTALL +++ b/INSTALL @@ -19,7 +19,7 @@ Create daemontools+ucspi-tcp service: cd /path/to/pastes umask 027 exec setuidgid paster tcpserver -DHR -l 0 ::0 2020 \ - $GOPATH/bin/paster http://paster.example.com/ 2>&1 + timeout 1m $GOPATH/bin/paster http://paster.example.com/ 2>&1 EOF # cat > /var/service/.paster/log/run <&1 + timeout 1m $GOPATH/bin/paster http://paster.example.com/ 2>&1 diff --git a/main.go b/main.go index 9f65a79..34bdd4a 100644 --- a/main.go +++ b/main.go @@ -29,7 +29,6 @@ import ( "io" "os" "strconv" - "time" ) func fatal(s string) { @@ -38,7 +37,6 @@ func fatal(s string) { } func main() { - maxSecs := flag.Uint("max-secs", 60, "Maximal time of aliveness (0=disable)") maxSize := flag.Uint64("max-size", 1<<20, "Maximal upload size") flag.Usage = func() { fmt.Fprintf(os.Stderr, "Usage: paster [options] URL [...]\n") @@ -50,15 +48,6 @@ func main() { os.Exit(1) } var fn string - if *maxSecs > 0 { - go func() { - time.Sleep(time.Duration(*maxSecs) * time.Second) - if fn != "" { - os.Remove(fn) - } - fatal("max aliveness time is reached") - }() - } r := bufio.NewReader(os.Stdin) b, err := r.ReadByte() if err != nil {