Skip to content

Commit

Permalink
custom port
Browse files Browse the repository at this point in the history
  • Loading branch information
MinatoHikari committed May 30, 2021
1 parent cdc7fb2 commit 6f88811
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"github.com/spf13/viper"
"strings"
)

// Config 配置.
Expand Down Expand Up @@ -54,3 +55,14 @@ func GetToken() *string {

return &token
}

func GetPort() string {
port := Config.GetString("port")
if port != "" {
port = strings.Join([]string{":", port}, "")
} else {
port = ":8079"
}

return port
}
3 changes: 2 additions & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ script = "build:dev"
dist = "./dist"
token = "xxxxxxxxxxxxxx"
branch = "main"
logPath = "/usr/local/var/webhook.log"
logPath = "/usr/local/var/webhook.log"
port = "8079"
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func main() {

InitLog(app)

err := app.Listen(":8079")
err := app.Listen(GetPort())
if err != nil {
fmt.Println("service start failed:", err)
}
Expand Down

0 comments on commit 6f88811

Please sign in to comment.