From: Sergey Matveev <stargrave@stargrave.org>
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/?a=commitdiff_plain;h=8bc46fea362cef7900632a9587d8f5f540e5976e;p=paster.git

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 <<EOF
     #!/bin/sh -e
@@ -54,4 +54,4 @@ or likely go.cypherpunks.ru/ucspi/cmd/tlss:
 
     exec setuidgid paster tcpserver -DHR -l 0 ::0 2021 tlss \
         -key paster.example.com.key.pem -cert paster.example.com.pem \
-        $GOPATH/bin/paster http://paster.example.com/ 2>&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 {