service.go 602 B

12345678910111213141516171819202122232425262728293031
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "apklink/service/internal/config"
  6. "apklink/service/internal/handler"
  7. "apklink/service/internal/svc"
  8. "github.com/zeromicro/go-zero/core/conf"
  9. "github.com/zeromicro/go-zero/rest"
  10. )
  11. var configFile = flag.String("f", "etc/service-api.yaml", "the config file")
  12. func main() {
  13. flag.Parse()
  14. var c config.Config
  15. conf.MustLoad(*configFile, &c)
  16. ctx := svc.NewServiceContext(c)
  17. server := rest.MustNewServer(c.RestConf)
  18. defer server.Stop()
  19. handler.RegisterHandlers(server, ctx)
  20. fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
  21. server.Start()
  22. }