2023-08-08 10:28:43 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.coopgo.io/coopgo-apps/silvermobi/handler"
|
|
|
|
grpcserver "git.coopgo.io/coopgo-apps/silvermobi/servers/grpcapi/server"
|
|
|
|
"git.coopgo.io/coopgo-apps/silvermobi/services"
|
|
|
|
"git.coopgo.io/coopgo-apps/silvermobi/storage"
|
|
|
|
"github.com/rs/zerolog"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
|
|
|
|
|
|
|
cfg, err := ReadConfig()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
grpc_enable = cfg.GetBool("services.external.grpc.enable")
|
|
|
|
)
|
|
|
|
|
|
|
|
services, err := services.NewServicesHandler(cfg)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal().Err(err).Msg("failed starting services handler")
|
|
|
|
}
|
2023-12-08 06:35:04 +00:00
|
|
|
storage, err := storage.NewPostgresqlStorage(cfg)
|
2023-08-08 10:28:43 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal().Err(err).Msg("failed starting storage handler")
|
|
|
|
}
|
|
|
|
|
2023-12-08 06:35:04 +00:00
|
|
|
handler, err := handler.NewSilvermobiHandler(cfg, services, storage)
|
2023-08-08 10:28:43 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal().Err(err).Msg("failed starting ridygo handler")
|
|
|
|
}
|
|
|
|
failed := make(chan error)
|
|
|
|
|
|
|
|
if grpc_enable {
|
|
|
|
log.Info().Msg("Running gRPC server")
|
|
|
|
go grpcserver.Run(failed, cfg, handler)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = <-failed
|
|
|
|
|
|
|
|
log.Fatal().Err(err).Msg("Terminating")
|
|
|
|
}
|