forked from security/hakurei
cmd/pkgserver: specify full addr string in flag
This allows greater flexibility. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -24,7 +23,7 @@ func main() {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
flagBaseDir string
|
flagBaseDir string
|
||||||
flagPort int
|
flagAddr string
|
||||||
)
|
)
|
||||||
|
|
||||||
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
|
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
|
||||||
@@ -68,15 +67,15 @@ func main() {
|
|||||||
}
|
}
|
||||||
uiRoutes(http.DefaultServeMux)
|
uiRoutes(http.DefaultServeMux)
|
||||||
apiRoutes(http.DefaultServeMux, &index)
|
apiRoutes(http.DefaultServeMux, &index)
|
||||||
return http.ListenAndServe(fmt.Sprintf(":%d", flagPort), nil)
|
return http.ListenAndServe(flagAddr, nil)
|
||||||
}).Flag(
|
}).Flag(
|
||||||
&flagBaseDir,
|
&flagBaseDir,
|
||||||
"b", command.StringFlag(""),
|
"b", command.StringFlag(""),
|
||||||
"base directory for cache",
|
"base directory for cache",
|
||||||
).Flag(
|
).Flag(
|
||||||
&flagPort,
|
&flagAddr,
|
||||||
"p", command.IntFlag(8067),
|
"addr", command.StringFlag(":8067"),
|
||||||
"http listen port",
|
"TCP network address to listen on",
|
||||||
)
|
)
|
||||||
c.MustParse(os.Args[1:], func(e error) {
|
c.MustParse(os.Args[1:], func(e error) {
|
||||||
log.Fatal(e)
|
log.Fatal(e)
|
||||||
|
|||||||
Reference in New Issue
Block a user