summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/www-kilabit/main.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/cmd/www-kilabit/main.go b/cmd/www-kilabit/main.go
index cfbcb41..54eef6a 100644
--- a/cmd/www-kilabit/main.go
+++ b/cmd/www-kilabit/main.go
@@ -7,8 +7,10 @@ import (
"flag"
"log"
"strings"
+ "time"
"git.sr.ht/~shulhan/ciigo"
+ "git.sr.ht/~shulhan/pakakeh.go/lib/http"
"git.sr.ht/~shulhan/pakakeh.go/lib/memfs"
"git.sr.ht/~shulhan/pakakeh.go/lib/systemd"
)
@@ -26,18 +28,30 @@ func main() {
HTMLTemplate: `_content/template.gohtml`,
}
serveOpts = ciigo.ServeOptions{
- ConvertOptions: convertOpts,
- Mfs: memfsContent,
+ ServerOptions: http.ServerOptions{
+ Memfs: memfsContent,
+ },
}
+ shutdownIdleDuration string
+
cmd string
err error
)
flag.BoolVar(&serveOpts.IsDevelopment, "dev", false, "Run in development mode")
flag.StringVar(&serveOpts.Address, `address`, `127.0.0.1:7000`, `Address to serve`)
+ flag.StringVar(&shutdownIdleDuration, `shutdown-idle`, ``,
+ `Shutdown the server after specific duration`)
flag.Parse()
+ if shutdownIdleDuration != `` {
+ serveOpts.ShutdownIdleDuration, err = time.ParseDuration(shutdownIdleDuration)
+ if err != nil {
+ log.Fatalf(`invalid shutdown-idle value %s: %s`, shutdownIdleDuration, err)
+ }
+ }
+
cmd = strings.ToLower(flag.Arg(0))
switch cmd {
@@ -71,7 +85,7 @@ func main() {
gotAddr, serveOpts.Address)
}
}
- err = ciigo.Serve(serveOpts)
+ err = ciigo.Serve(serveOpts, convertOpts)
if err != nil {
log.Fatal(err)
}