feat: allow changing the listening port (#70)

Allow changing the listening port via command line or configuration
file.

Signed-off-by: cubercsl <2014cais01@gmail.com>
This commit is contained in:
cubercsl
2023-10-11 15:56:59 +08:00
committed by GitHub
parent c40e27c3b4
commit 482d1d0291

View File

@@ -36,7 +36,7 @@ func main() {
registerRoute(r)
srv := &http.Server{
Addr: ":8080",
Addr: viper.GetString("listen"),
Handler: r,
}
@@ -64,6 +64,7 @@ func runServer(srv *http.Server) {
func parseFlag() {
pflag.StringP("configFile", "c", "config.yaml", "config file")
pflag.StringP("listen", "l", ":8080", "listen address")
pflag.BoolP("version", "v", false, "version information")
pflag.Parse()
if err := viper.BindPFlags(pflag.CommandLine); err != nil {