44 lines
847 B
Go
44 lines
847 B
Go
package hub
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
"time"
|
|
|
|
"git.crumpington.com/lib/webutil"
|
|
)
|
|
|
|
func Main() {
|
|
log.SetFlags(0)
|
|
|
|
conf := Config{}
|
|
flag.StringVar(&conf.RootDir, "root-dir", "", "[REQUIRED] Root directory.")
|
|
flag.StringVar(&conf.ListenAddr, "listen", "", "[REQUIRED] Listen address.")
|
|
flag.BoolVar(&conf.Insecure, "insecure", false, "Don't use secure cookies.")
|
|
|
|
flag.Parse()
|
|
|
|
if conf.RootDir == "" || conf.ListenAddr == "" {
|
|
flag.Usage()
|
|
os.Exit(1)
|
|
}
|
|
|
|
app, err := NewApp(conf)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
srv := &http.Server{
|
|
Addr: conf.ListenAddr,
|
|
Handler: app.Handler(),
|
|
ReadHeaderTimeout: 30 * time.Second,
|
|
ReadTimeout: 60 * time.Second,
|
|
WriteTimeout: 120 * time.Second,
|
|
IdleTimeout: 180 * time.Second,
|
|
}
|
|
|
|
log.Fatal(webutil.ListenAndServe(srv))
|
|
}
|