idecnode/cmd/api/api.go

35 lines
702 B
Go

package api
import (
"github.com/urfave/cli/v2"
"gitrepo.ru/neonxp/idecnode/pkg/api"
"gitrepo.ru/neonxp/idecnode/pkg/config"
"gitrepo.ru/neonxp/idecnode/pkg/idec"
)
var APICommand *cli.Command = &cli.Command{
Name: "api",
Description: "Start api server",
Action: func(c *cli.Context) error {
configPath := c.String("config")
cfg, err := config.New(configPath)
if err != nil {
return err
}
idecApi, err := idec.New(cfg)
if err != nil {
return err
}
defer idecApi.Close()
return api.New(idecApi, cfg).Run(c.Context)
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "config",
DefaultText: "config path",
Value: "./etc/node.yaml",
},
},
}