You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
paopao-ce/main.go

69 lines
1.5 KiB

2 years ago
package main
import (
"flag"
2 years ago
"fmt"
"net/http"
"strings"
2 years ago
"github.com/fatih/color"
2 years ago
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-ce/internal"
"github.com/rocboss/paopao-ce/internal/conf"
"github.com/rocboss/paopao-ce/internal/routers"
"github.com/rocboss/paopao-ce/pkg/debug"
"github.com/rocboss/paopao-ce/pkg/util"
)
var (
version, commitID, buildDate string
noDefaultFeatures bool
features suites
2 years ago
)
type suites []string
func (s *suites) String() string {
return strings.Join(*s, ",")
}
func (s *suites) Set(value string) error {
for _, item := range strings.Split(value, ",") {
*s = append(*s, strings.TrimSpace(item))
}
return nil
}
func init() {
flagParse()
conf.Initialize(features, noDefaultFeatures)
internal.Initialize()
}
func flagParse() {
flag.BoolVar(&noDefaultFeatures, "no-default-features", false, "whether use default features")
flag.Var(&features, "features", "use special features")
flag.Parse()
}
2 years ago
func main() {
gin.SetMode(conf.ServerSetting.RunMode)
2 years ago
router := routers.NewRouter()
s := &http.Server{
Addr: conf.ServerSetting.HttpIp + ":" + conf.ServerSetting.HttpPort,
2 years ago
Handler: router,
ReadTimeout: conf.ServerSetting.ReadTimeout,
WriteTimeout: conf.ServerSetting.WriteTimeout,
2 years ago
MaxHeaderBytes: 1 << 20,
}
util.PrintHelloBanner(debug.VersionInfo())
fmt.Fprintf(color.Output, "PaoPao service listen on %s\n",
color.GreenString(fmt.Sprintf("http://%s:%s", conf.ServerSetting.HttpIp, conf.ServerSetting.HttpPort)),
)
2 years ago
s.ListenAndServe()
}