Browse Source

fix hint

pull/253/head
yedf2 4 years ago
parent
commit
19d0ef19a9
  1. 11
      dashboard/vite.config.ts
  2. 12
      dtmsvr/entry/main.go
  3. 2
      dtmsvr/microservices/drivers.go
  4. 4
      dtmsvr/svr.go
  5. 5
      main.go

11
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: [

12
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
}

2
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"

4
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

5
main.go

@ -15,5 +15,8 @@ import (
var Version string
func main() {
entry.Main(&Version)
app := entry.Main(&Version)
if app != nil {
select {}
}
}

Loading…
Cancel
Save