Skip to content

Commit 482d1d0

Browse files
authored
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>
1 parent c40e27c commit 482d1d0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cmd/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func main() {
3636
registerRoute(r)
3737

3838
srv := &http.Server{
39-
Addr: ":8080",
39+
Addr: viper.GetString("listen"),
4040
Handler: r,
4141
}
4242

@@ -64,6 +64,7 @@ func runServer(srv *http.Server) {
6464

6565
func parseFlag() {
6666
pflag.StringP("configFile", "c", "config.yaml", "config file")
67+
pflag.StringP("listen", "l", ":8080", "listen address")
6768
pflag.BoolP("version", "v", false, "version information")
6869
pflag.Parse()
6970
if err := viper.BindPFlags(pflag.CommandLine); err != nil {

0 commit comments

Comments
 (0)