aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorShulhan <m.shulhan@gmail.com>2026-02-11 22:58:06 +0700
committerShulhan <m.shulhan@gmail.com>2026-04-09 22:18:08 +0700
commit3976d893c3015e0c56c47f88acd880646c6fec58 (patch)
tree728f419f650db6b936bee903afabe0479c6ae30a /cmd
parente8fbdf75658c2bb88bc9e3bbd8b23c30709d0502 (diff)
downloadgo-x-proposal-3976d893c3015e0c56c47f88acd880646c6fec58.tar.xz
cmd/www-go-proposal: add base path and option to shutdown idle durationHEADmain
The www-go-proposal now is served under "/proposal" so no need to reroute them in proxy. The "-shutdown-idle" option allow to set the duration when server will automatically shutting down when no new connections accepted after specific duration.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/www-go-proposal/main.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/cmd/www-go-proposal/main.go b/cmd/www-go-proposal/main.go
index 2581186..c31da25 100644
--- a/cmd/www-go-proposal/main.go
+++ b/cmd/www-go-proposal/main.go
@@ -8,6 +8,7 @@ import (
"flag"
"log"
"strings"
+ "time"
"git.sr.ht/~shulhan/ciigo"
"git.sr.ht/~shulhan/pakakeh.go/lib/http"
@@ -35,19 +36,31 @@ func main() {
}
var serveOpts = ciigo.ServeOptions{
ServerOptions: http.ServerOptions{
- Memfs: memFS,
+ BasePath: `/proposal`,
+ Memfs: memFS,
},
}
+ var shutdownIdleDuration string
flag.BoolVar(&serveOpts.IsDevelopment, `dev`, false,
`Turn on development mode.`)
flag.StringVar(&serveOpts.Address, `http`, `127.0.0.1:10202`,
- `Set HTTP listen address`)
+ `Set HTTP listen address`)
+ flag.StringVar(&shutdownIdleDuration, `shutdown-idle`, ``,
+ `Set the duration to automatically shutdown the server when no new connections after a duration.`)
flag.Parse()
+ var err error
+ if shutdownIdleDuration != `` {
+ serveOpts.ShutdownIdleDuration, err = time.ParseDuration(shutdownIdleDuration)
+ if err != nil {
+ log.Fatalf(`invalid shutdown-idle value %s: %s`,
+ shutdownIdleDuration, err)
+ }
+ }
+
var cmd = strings.ToLower(flag.Arg(0))
- var err error
switch cmd {
case `embed`:
err = ciigo.GoEmbed(embedOpts)