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

main.go 1.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright © 2023 OpenIM open source community. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package main
  15. import (
  16. "flag"
  17. "fmt"
  18. "github.com/OpenIMSDK/OpenKF/server/internal/config"
  19. "github.com/OpenIMSDK/OpenKF/server/internal/conn/client"
  20. "github.com/OpenIMSDK/OpenKF/server/internal/conn/db"
  21. "github.com/OpenIMSDK/OpenKF/server/internal/middleware/hooks"
  22. "github.com/OpenIMSDK/OpenKF/server/internal/router"
  23. "github.com/OpenIMSDK/OpenKF/server/internal/utils"
  24. "github.com/OpenIMSDK/OpenKF/server/pkg/log"
  25. "github.com/OpenIMSDK/OpenKF/server/pkg/server"
  26. )
  27. func init() {
  28. // arg
  29. configPath := flag.String("c", "./config.yaml", "config file path")
  30. flag.Parse()
  31. // init
  32. config.ConfigInit(*configPath)
  33. utils.OpenKFBanner()
  34. log.InitLogger()
  35. db.InitMysqlDB()
  36. db.InitRedisDB()
  37. client.InitMinio()
  38. hooks.InitHooks()
  39. }
  40. //go:generate go env -w GO111MODULE=on
  41. //go:generate go env -w GOPROXY=https://goproxy.cn,direct
  42. //go:generate go mod tidy
  43. //go:generate go mod download
  44. func main() {
  45. serverAddress := fmt.Sprintf("%s:%d", config.Config.Server.Ip, config.Config.Server.Port)
  46. r := router.InitRouter()
  47. s := server.InitServer(serverAddress, r)
  48. log.Error("server start error: %v", s.ListenAndServe().Error())
  49. }