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
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
"io"
"os"
"strconv"
- "time"
)
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")
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 {