Skip to content

Commit

Permalink
fix port
Browse files Browse the repository at this point in the history
  • Loading branch information
herlon214 committed Dec 4, 2021
1 parent 488ea9a commit ae60394
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cmd/server/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ 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) {
// Context
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
}
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit ae60394

Please sign in to comment.