Files
open-im-server/cmd/api/main.go
T

36 lines
900 B
Go
Raw Normal View History

2021-05-26 19:15:25 +08:00
package main
import (
2023-02-23 19:15:30 +08:00
"OpenIM/internal/api"
"OpenIM/internal/api/third"
"OpenIM/pkg/common/config"
"OpenIM/pkg/common/log"
2021-05-26 19:15:25 +08:00
"flag"
2022-04-06 15:33:16 +08:00
"fmt"
2022-07-31 01:14:26 +08:00
2021-05-26 19:15:25 +08:00
"strconv"
2023-02-23 19:15:30 +08:00
"OpenIM/pkg/common/constant"
2021-05-26 19:15:25 +08:00
)
func main() {
2023-02-24 17:42:01 +08:00
if err := config.InitConfig(); err != nil {
2023-02-23 19:51:58 +08:00
panic(err.Error())
}
2023-02-24 17:42:01 +08:00
log.NewPrivateLog(constant.LogFileName)
router := api.NewGinRouter()
2023-02-24 11:51:07 +08:00
ginPort := flag.Int("port", config.Config.Api.GinPort[0], "get ginServerPort from cmd,default 10002 as port")
flag.Parse()
2022-05-07 19:52:18 +08:00
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
if config.Config.Api.ListenIP != "" {
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
}
2023-02-24 17:42:01 +08:00
go third.MinioInit()
2022-12-14 16:14:56 +08:00
fmt.Println("start api server, address: ", address, ", OpenIM version: ", constant.CurrentVersion)
2023-02-23 19:15:30 +08:00
err := router.Run(address)
2022-04-06 15:33:16 +08:00
if err != nil {
2022-09-14 12:31:24 +08:00
log.Error("", "api run failed ", address, err.Error())
panic("api start failed " + err.Error())
2022-04-06 15:33:16 +08:00
}
2021-05-26 19:15:25 +08:00
}