You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2023/02/27 07:35:25 UTC

[incubator-devlake] branch main updated: fix: fix port (#4518)

This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new bad597644 fix: fix port (#4518)
bad597644 is described below

commit bad5976445fb57af01a78c3fdd59dfb443842798
Author: mappjzc <zh...@merico.dev>
AuthorDate: Mon Feb 27 15:35:19 2023 +0800

    fix: fix port (#4518)
    
    Fix the problem that HOST information needs to be included in PORT.
    
    Nddtfjiang <zh...@merico.dev>
---
 .env.example                        |  2 +-
 backend/core/config/config_viper.go |  2 +-
 backend/server/api/api.go           | 13 +++++++++----
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/.env.example b/.env.example
index d906ac405..a66eaf195 100644
--- a/.env.example
+++ b/.env.example
@@ -12,7 +12,7 @@ E2E_DB_URL=mysql://merico:merico@mysql:3306/lake_test?charset=utf8mb4&parseTime=
 DB_LOGGING_LEVEL=Error
 
 # Lake REST API
-PORT=:8080
+PORT=8080
 MODE=release
 
 NOTIFICATION_ENDPOINT=
diff --git a/backend/core/config/config_viper.go b/backend/core/config/config_viper.go
index 85b3da07d..be3106f93 100644
--- a/backend/core/config/config_viper.go
+++ b/backend/core/config/config_viper.go
@@ -71,7 +71,7 @@ func getEnvPath() string {
 // Set default value for no .env or .env not set it
 func setDefaultValue(v *viper.Viper) {
 	v.SetDefault("DB_URL", "mysql://merico:merico@mysql:3306/lake?charset=utf8mb4&parseTime=True")
-	v.SetDefault("PORT", ":8080")
+	v.SetDefault("PORT", "8080")
 	v.SetDefault("PLUGIN_DIR", "bin/plugins")
 	v.SetDefault("TEMPORAL_TASK_QUEUE", "DEVLAKE_TASK_QUEUE")
 	v.SetDefault("TAP_PROPERTIES_DIR", "resources/tap")
diff --git a/backend/server/api/api.go b/backend/server/api/api.go
index 46a2802ed..97dd76136 100644
--- a/backend/server/api/api.go
+++ b/backend/server/api/api.go
@@ -18,9 +18,9 @@ limitations under the License.
 package api
 
 import (
+	"fmt"
 	"net/http"
 	"strconv"
-	"strings"
 	"time"
 
 	"github.com/apache/incubator-devlake/core/config"
@@ -107,7 +107,12 @@ func CreateApiService() {
 	if remotePluginsEnabled {
 		go bootstrapRemotePlugins(v)
 	}
-	err := router.Run(port)
+	portNum, err := strconv.Atoi(port)
+	if err != nil {
+		panic(fmt.Errorf("PORT [%s] must be int: %s", port, err.Error()))
+	}
+
+	err = router.Run(fmt.Sprintf("0.0.0.0:%d", portNum))
 	if err != nil {
 		panic(err)
 	}
@@ -115,9 +120,9 @@ func CreateApiService() {
 
 func bootstrapRemotePlugins(v *viper.Viper) {
 	port := v.GetString("PORT")
-	portNum, err := strconv.Atoi(strings.Split(port, ":")[1])
+	portNum, err := strconv.Atoi(port)
 	if err != nil {
-		panic(err)
+		panic(fmt.Errorf("PORT [%s] must be int: %s", port, err.Error()))
 	}
 	err = bridge.Bootstrap(v, portNum)
 	if err != nil {