添加多环境配置
This commit is contained in:
parent
b81011d362
commit
a8a95ad253
11
cmd/app.go
11
cmd/app.go
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@ -13,7 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
os.Setenv(constant.ConfigFileEnvKey, "../conf/dubbogo.yaml")
|
initEnv()
|
||||||
config.SetProviderService(&service.FilesProvider{})
|
config.SetProviderService(&service.FilesProvider{})
|
||||||
if err := config.Load(); err != nil {
|
if err := config.Load(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -24,3 +25,11 @@ func main() {
|
|||||||
log.Printf("Caught signal %s: shutting down.", sig)
|
log.Printf("Caught signal %s: shutting down.", sig)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func initEnv() {
|
||||||
|
if os.Getenv("MODE_ENV") != "" {
|
||||||
|
os.Setenv(constant.ConfigFileEnvKey, fmt.Sprintf("./conf/%s/%s", os.Getenv("MODE_ENV"), "dubbogo.yaml"))
|
||||||
|
} else {
|
||||||
|
os.Setenv(constant.ConfigFileEnvKey, "../conf/dubbogo.yaml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
14
conf/dev/dubbogo.yaml
Normal file
14
conf/dev/dubbogo.yaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
dubbo:
|
||||||
|
registries:
|
||||||
|
demoZK:
|
||||||
|
protocol: zookeeper
|
||||||
|
address: 172.16.100.93:2181
|
||||||
|
protocols:
|
||||||
|
triple:
|
||||||
|
name: tri
|
||||||
|
port: 20027
|
||||||
|
provider:
|
||||||
|
services:
|
||||||
|
FileProvider:
|
||||||
|
protocol: tri
|
||||||
|
interface: files.File # must be compatible with grpc or dubbo-java
|
14
conf/prod/dubbogo.yaml
Normal file
14
conf/prod/dubbogo.yaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
dubbo:
|
||||||
|
registries:
|
||||||
|
demoZK:
|
||||||
|
protocol: zookeeper
|
||||||
|
address: zookeeper:2181
|
||||||
|
protocols:
|
||||||
|
triple:
|
||||||
|
name: tri
|
||||||
|
port: 20027
|
||||||
|
provider:
|
||||||
|
services:
|
||||||
|
FileProvider:
|
||||||
|
protocol: tri
|
||||||
|
interface: files.File # must be compatible with grpc or dubbo-java
|
Loading…
Reference in New Issue
Block a user