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.

60 lines
1.2 KiB

2 years ago
  1. package main
  2. import (
  3. "fmt"
  4. "gitea.baoapi.com/root/stu_uuos/lib/logruspan"
  5. "log"
  6. "time"
  7. "gitea.baoapi.com/root/stu_uuos/lib/nats"
  8. "gitea.baoapi.com/root/stu_uuos/lib/redis"
  9. "gitea.baoapi.com/root/stu_uuos/micro"
  10. "gitea.baoapi.com/root/stu_uuos/web/router"
  11. "github.com/micro/go-micro/v2/web"
  12. "gitea.baoapi.com/root/stu_uuos/config"
  13. "gitea.baoapi.com/root/stu_uuos/lib/db"
  14. "gitea.baoapi.com/root/stu_uuos/logger"
  15. _ "github.com/micro/go-plugins/registry/kubernetes/v2"
  16. )
  17. func init() {
  18. config.Init()
  19. logger.Init()
  20. logruspan.LogInitHttp()
  21. db.Init()
  22. db.InitTable()
  23. redis.Init()
  24. nats.Init()
  25. micro.InitMicro()
  26. //监听同步任务
  27. }
  28. func main() {
  29. service := web.NewService(
  30. web.Name(config.GetConfig().ServiceName),
  31. web.Version(config.GetConfig().Version),
  32. web.Address(fmt.Sprintf(":%d", config.GetConfig().Address)),
  33. web.RegisterTTL(time.Second*30),
  34. web.RegisterInterval(time.Second*15),
  35. web.Handler(router.Init()),
  36. web.AfterStop(func() error {
  37. return db.Close()
  38. }),
  39. //web.Secure(true),
  40. //web.TLSConfig(gomicro.LoadTlsConfig()),
  41. )
  42. //handler.InitDatab()
  43. if err := service.Init(); err != nil {
  44. log.Fatal(err)
  45. }
  46. if err := service.Run(); err != nil {
  47. log.Fatal(err)
  48. }
  49. }
  50. // t1