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 2.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. slackcmd "github.com/OpenIMSDK/OpenKF/server/internal/msg/slack_cmd"
  23. "github.com/OpenIMSDK/OpenKF/server/internal/router"
  24. "github.com/OpenIMSDK/OpenKF/server/internal/utils"
  25. "github.com/OpenIMSDK/OpenKF/server/pkg/log"
  26. "github.com/OpenIMSDK/OpenKF/server/pkg/server"
  27. )
  28. func init() {
  29. // arg
  30. configPath := flag.String("c", "./config.yaml", "config file path")
  31. flag.Parse()
  32. // init
  33. config.ConfigInit(*configPath)
  34. utils.OpenKFBanner()
  35. log.InitLogger()
  36. db.InitMysqlDB()
  37. db.InitRedisDB()
  38. client.InitMinio()
  39. // client.InitMail()
  40. hooks.InitHooks()
  41. }
  42. //go:generate go env -w GO111MODULE=on
  43. //go:generate go env -w GOPROXY=https://goproxy.cn,direct
  44. //go:generate go mod tidy
  45. //go:generate go mod download
  46. // @title OpenKF Server
  47. // @version v0.2.0
  48. // @description OpenKF Server API Docs.
  49. // @securityDefinitions.apikey ApiKeyAuth
  50. // @in header
  51. // @name Authorization.
  52. func main() {
  53. serverAddress := fmt.Sprintf("%s:%d", config.Config.Server.Ip, config.Config.Server.Port)
  54. // Add slack server
  55. go slackcmd.InitSlackListen()
  56. r := router.InitRouter()
  57. s := server.InitServer(serverAddress, r)
  58. log.Error("server start error: %v", s.ListenAndServe().Error())
  59. }