cmd/pkgserver: specify full addr string in flag

This allows greater flexibility.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-03-11 01:49:42 +09:00
parent 534cac83fb
commit b03ad185de

View File

@@ -3,7 +3,6 @@ package main
import (
"context"
"errors"
"fmt"
"log"
"net/http"
"os"
@@ -24,7 +23,7 @@ func main() {
var (
flagBaseDir string
flagPort int
flagAddr string
)
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
@@ -68,15 +67,15 @@ func main() {
}
uiRoutes(http.DefaultServeMux)
apiRoutes(http.DefaultServeMux, &index)
return http.ListenAndServe(fmt.Sprintf(":%d", flagPort), nil)
return http.ListenAndServe(flagAddr, nil)
}).Flag(
&flagBaseDir,
"b", command.StringFlag(""),
"base directory for cache",
).Flag(
&flagPort,
"p", command.IntFlag(8067),
"http listen port",
&flagAddr,
"addr", command.StringFlag(":8067"),
"TCP network address to listen on",
)
c.MustParse(os.Args[1:], func(e error) {
log.Fatal(e)