From ae60394f49b5833d1b56ef2e5e528ec2ae663ea1 Mon Sep 17 00:00:00 2001 From: Herlon Aguiar Date: Sat, 4 Dec 2021 22:23:44 +0100 Subject: [PATCH] fix port --- cmd/server/run.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/server/run.go b/cmd/server/run.go index 31e058d..493405a 100644 --- a/cmd/server/run.go +++ b/cmd/server/run.go @@ -19,9 +19,10 @@ import ( ) var RunCmd = &cobra.Command{ - Use: "run", - Short: "Starts the webhook server", - Run: Run, + Use: "run", + Short: "Starts the webhook server", + Run: Run, + TraverseChildren: true, } func Run(cmd *cobra.Command, args []string) { @@ -29,9 +30,8 @@ func Run(cmd *cobra.Command, args []string) { ctx := context.Background() // Environment - port := os.Getenv("PORT") - if port == "" { - logrus.Panicln("PORT is required") + if serverPort <= 0 { + logrus.Panicln("A valid --port is required") return } @@ -67,8 +67,8 @@ func Run(cmd *cobra.Command, args []string) { // Listen http.HandleFunc("/webhook", WebhookHandler(webhookSecret, sonar, gh)) - logrus.Infoln("Listening on port", port) - if err := http.ListenAndServe(fmt.Sprintf(":%s", port), nil); err != nil { + logrus.Infoln("Listening on port", serverPort) + if err := http.ListenAndServe(fmt.Sprintf(":%d", serverPort), nil); err != nil { panic(err) } }