luoyangwei 1 anno fa
parent
commit
46c6faf36b
8 ha cambiato i file con 13 aggiunte e 9 eliminazioni
  1. 1 4
      .gitlab-ci.yml
  2. 2 3
      config/config.go
  3. 2 0
      etc/websocket.debug.yaml
  4. 2 0
      etc/websocket.release.yaml
  5. 2 0
      etc/websocket.test.yaml
  6. 1 1
      go.mod
  7. 2 0
      go.sum
  8. 1 1
      websocket.go

+ 1 - 4
.gitlab-ci.yml

@@ -35,7 +35,7 @@ build-websocket-job:
         - go env -w GOARCH=amd64
         - go mod tidy
         - go build -o websocket .
-        - ls
+        - cp -rf websocket /usr/bin/websocket
 
 deploy-job:
     stage: deploy
@@ -44,8 +44,5 @@ deploy-job:
     only:
         - test
     script: 
-        - pwd
-        - cp -rf * /data/server-websocket
-        - ls
         - supervisorctl update
         - supervisorctl restart websocket-node-1 websocket-node-2

+ 2 - 3
config/config.go

@@ -15,7 +15,6 @@ func loadWebsocketConfig() error {
 
 // MustLoadConfig 加载配置
 func MustLoadConfig(file string) {
-	confx.SetEnvConfig("ENVIRONMENT")
 	if err := confx.LoadConfig(file, loadWebsocketConfig); err != nil {
 		log.Fatalln(err)
 	}
@@ -23,5 +22,5 @@ func MustLoadConfig(file string) {
 }
 
 func GetEnvironment() string {
-	return viper.GetString("ENVIRONMENT")
-}
+	return viper.GetString("environment")
+}

+ 2 - 0
etc/websocket.local.yaml → etc/websocket.debug.yaml

@@ -1,3 +1,5 @@
+environment: debug
+
 auth:
     server_auth_secret: "992443c835c347d6a8b7d046d0261671"
 

+ 2 - 0
etc/websocket.release.yaml

@@ -1,3 +1,5 @@
+
+environment: debug
 websocket:
     connect_size: 1024
     heartbeat_wait: 360

+ 2 - 0
etc/websocket.test.yaml

@@ -1,3 +1,5 @@
+environment: test
+
 auth:
     server_auth_secret: "992443c835c347d6a8b7d046d0261671"
 

+ 1 - 1
go.mod

@@ -17,7 +17,7 @@ require (
 	github.com/spf13/viper v1.18.2
 	go.uber.org/zap v1.27.0
 	gorm.io/gorm v1.25.7
-	x.sikey.com.cn/serverx v1.2.28
+	x.sikey.com.cn/serverx v1.2.29
 )
 
 // replace x.sikey.com.cn/serverx v1.2.26 => ../serverx

+ 2 - 0
go.sum

@@ -319,3 +319,5 @@ nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYm
 rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
 x.sikey.com.cn/serverx v1.2.28 h1:2NaXovSVsZGqe3Cofwxx9KWjVuJmFN+5skBLJWUof68=
 x.sikey.com.cn/serverx v1.2.28/go.mod h1:+jho37jloxhYP66RsEKw4Qc+bcoInP/zWP4/Xhx18GM=
+x.sikey.com.cn/serverx v1.2.29 h1:2vAFnSYvA0a21UT3j/3yhZ3LWI6WEE+MrY9WCjUT4gA=
+x.sikey.com.cn/serverx v1.2.29/go.mod h1:+jho37jloxhYP66RsEKw4Qc+bcoInP/zWP4/Xhx18GM=

+ 1 - 1
websocket.go

@@ -24,7 +24,7 @@ import (
 var name = flag.String("n", "w303", "the name of the server")
 var port = flag.Int64("p", 8080, "the port of the server")
 var nodeId = flag.Int64("i", 1, "the node id of the server")
-var configFile = flag.String("f", "./etc/websocket.local.yaml", "the config file")
+var configFile = flag.String("f", "./etc/websocket.debug.yaml", "the config file")
 
 func main() {
 	time.Local = time.UTC