parent
7d25a9e65b
commit
acd3a63213
|
@ -8,6 +8,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var httpHost string
|
var httpHost string
|
||||||
|
@ -16,6 +17,7 @@ var maxSize int64
|
||||||
var dir string
|
var dir string
|
||||||
var storeSize int64
|
var storeSize int64
|
||||||
var basepath string
|
var basepath string
|
||||||
|
var timeout int64
|
||||||
|
|
||||||
var stdout = log.New(os.Stdout, "[tusd] ", 0)
|
var stdout = log.New(os.Stdout, "[tusd] ", 0)
|
||||||
var stderr = log.New(os.Stderr, "[tusd] ", 0)
|
var stderr = log.New(os.Stderr, "[tusd] ", 0)
|
||||||
|
@ -27,6 +29,7 @@ func init() {
|
||||||
flag.StringVar(&dir, "dir", "./data", "Directory to store uploads in")
|
flag.StringVar(&dir, "dir", "./data", "Directory to store uploads in")
|
||||||
flag.Int64Var(&storeSize, "store-size", 0, "Size of disk space allowed to storage")
|
flag.Int64Var(&storeSize, "store-size", 0, "Size of disk space allowed to storage")
|
||||||
flag.StringVar(&basepath, "base-path", "/files/", "Basepath of the hTTP server")
|
flag.StringVar(&basepath, "base-path", "/files/", "Basepath of the hTTP server")
|
||||||
|
flag.Int64Var(&timeout, "timeout", 30*1000, "Read timeout for connections in milliseconds")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
@ -78,8 +81,13 @@ func main() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
http.Handle(basepath, http.StripPrefix(basepath, handler))
|
http.Handle(basepath, http.StripPrefix(basepath, handler))
|
||||||
err = http.ListenAndServe(address, nil)
|
|
||||||
if err != nil {
|
server := &http.Server{
|
||||||
|
Addr: address,
|
||||||
|
ReadTimeout: time.Duration(timeout) * time.Millisecond,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = server.ListenAndServe(); err != nil {
|
||||||
stderr.Fatalf("Unable to listen: %s", err)
|
stderr.Fatalf("Unable to listen: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue