]> Sergey Matveev's repositories - paster.git/commitdiff
timeout utility replaces -max-secs
authorSergey Matveev <stargrave@stargrave.org>
Fri, 15 Oct 2021 09:27:26 +0000 (12:27 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 15 Oct 2021 09:31:52 +0000 (12:31 +0300)
INSTALL
main.go

diff --git a/INSTALL b/INSTALL
index 53172209417ae4a5629a4eaadfcff492083ac367..28a9b0b0688036154d7e82836091032573c790bb 100644 (file)
--- 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 9f65a79dddf2f81e98c5f61a5d35608698019a6b..34bdd4a4bcea87cddd5a125d04c99342123e0dbc 100644 (file)
--- 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 {