diff --git a/dashboard/vite.config.ts b/dashboard/vite.config.ts index 6aa1f97..504a891 100644 --- a/dashboard/vite.config.ts +++ b/dashboard/vite.config.ts @@ -7,7 +7,7 @@ const setAlias = (alias: [string, string][]) => alias.map((v) => { return { find: v[0], replacement: path.resolve(__dirname, v[1]) }; }); -export default ({}: ConfigEnv): UserConfigExport => { +export default ({ }: ConfigEnv): UserConfigExport => { return { resolve: { alias: setAlias([['/@', 'src']]), @@ -19,6 +19,15 @@ export default ({}: ConfigEnv): UserConfigExport => { symbolId: 'icon-[dir]-[name]' }) ], + server: { + port: 5000, + base: 'dashboard', + proxy: { + '/api': { + target: 'http://localhost:36789', + }, + } + }, css: { postcss: { plugins: [ diff --git a/dtmsvr/entry/main.go b/dtmsvr/entry/main.go index b324344..4fcc717 100644 --- a/dtmsvr/entry/main.go +++ b/dtmsvr/entry/main.go @@ -10,6 +10,7 @@ import ( "github.com/dtm-labs/dtm/dtmsvr" "github.com/dtm-labs/dtm/dtmsvr/config" "github.com/dtm-labs/dtm/dtmsvr/storage/registry" + "github.com/gin-gonic/gin" "go.uber.org/automaxprocs/maxprocs" ) @@ -33,14 +34,15 @@ var isHelp = flag.Bool("h", false, "Show the help information about dtm.") var isReset = flag.Bool("r", false, "Reset dtm server data.") var confFile = flag.String("c", "", "Path to the server configuration file.") -func Main(version *string) { +// Main is the entry point of dtm server. +func Main(version *string) *gin.Engine { flag.Parse() if flag.NArg() > 0 || *isHelp { usage() - return + return nil } else if *isVersion { ver(version) - return + return nil } logger.Infof("dtm version is: %s", *version) config.MustLoadConfig(*confFile) @@ -54,7 +56,7 @@ func Main(version *string) { } _, _ = maxprocs.Set(maxprocs.Logger(logger.Infof)) registry.WaitStoreUp() - dtmsvr.StartSvr() // start dtmsvr api + app := dtmsvr.StartSvr() // start dtmsvr api go dtmsvr.CronExpiredTrans(-1) // start dtmsvr cron job - select {} + return app } diff --git a/dtmsvr/microservices/drivers.go b/dtmsvr/microservices/drivers.go index f74bc72..041070f 100644 --- a/dtmsvr/microservices/drivers.go +++ b/dtmsvr/microservices/drivers.go @@ -1,7 +1,7 @@ package microservices -// load the microserver driver import ( + // load the microserver drivers _ "github.com/dtm-labs/dtmdriver-gozero" _ "github.com/dtm-labs/dtmdriver-kratos" _ "github.com/dtm-labs/dtmdriver-polaris" diff --git a/dtmsvr/svr.go b/dtmsvr/svr.go index a9f266f..7dc7f5e 100644 --- a/dtmsvr/svr.go +++ b/dtmsvr/svr.go @@ -13,6 +13,7 @@ import ( "time" "github.com/dtm-labs/dtm/dtmgrpc" + "github.com/gin-gonic/gin" "github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/dtmcli/logger" @@ -24,7 +25,7 @@ import ( ) // StartSvr StartSvr -func StartSvr() { +func StartSvr() *gin.Engine { logger.Infof("start dtmsvr") setServerInfoMetrics() @@ -73,6 +74,7 @@ func StartSvr() { logger.Infof("RegisterGrpcService: %s", conf.MicroService.Driver) err = dtmdriver.GetDriver().RegisterGrpcService(conf.MicroService.Target, conf.MicroService.EndPoint) logger.FatalIfError(err) + return app } // PopulateDB setup mysql data diff --git a/main.go b/main.go index 78b539e..32e548e 100644 --- a/main.go +++ b/main.go @@ -15,5 +15,8 @@ import ( var Version string func main() { - entry.Main(&Version) + app := entry.Main(&Version) + if app != nil { + select {} + } }