cmd.go 639 Bytes
Newer Older
qiuqunfeng's avatar
qiuqunfeng committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
package app

import (
	"os"

	"github.com/spf13/cobra"
	"gitlab.com/security-rd/go-pkg/logging"
	"gitlab.com/tensorsecurity-rd/waf-console/api"
	"gitlab.com/tensorsecurity-rd/waf-console/internal/config"
)

func NewRootCommand() *cobra.Command {
	return &cobra.Command{
		Use:   "waf-console",
		Short: "Start waf-console service.",
		Args:  cobra.ExactArgs(0),
		RunE: func(cmd *cobra.Command, args []string) error {
			debugMode := os.Getenv("DEBUG_MODE")
			logging.Get().Info().Msgf("DEBUG_MODE: %s", debugMode)
			if debugMode == "true" {
				config.Conf.Debug = true
			}

			e := api.SetRouters()
			return e.Run(":8080")
		},
	}
}