mirror of
https://github.com/wonli/aqi.git
synced 2025-09-26 20:51:23 +08:00
36 lines
545 B
Cheetah
36 lines
545 B
Cheetah
package cmd
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/spf13/cobra"
|
|
"github.com/wonli/aqi"
|
|
|
|
"{{.PackageName}}/internal/dbc"
|
|
"{{.PackageName}}/internal/router"
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(api)
|
|
}
|
|
|
|
var api = &cobra.Command{
|
|
Use: "api",
|
|
Short: "启动API",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
app := aqi.Init(
|
|
aqi.ConfigFile(configFile),
|
|
aqi.HttpServer("Api", "apiPort"),
|
|
)
|
|
|
|
dbc.InitDBC()
|
|
|
|
g := gin.Default()
|
|
|
|
go router.Api(g)
|
|
go router.Actions(app)
|
|
|
|
app.WithHttpServer(g)
|
|
app.Start()
|
|
},
|
|
}
|