49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
|
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")
|
||
|
}
|
||
|
kvhandler, err := storage.NewKVHandler(cfg)
|
||
|
if err != nil {
|
||
|
log.Fatal().Err(err).Msg("failed starting storage handler")
|
||
|
}
|
||
|
|
||
|
handler, err := handler.NewSilvermobiHandler(cfg, services, kvhandler)
|
||
|
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")
|
||
|
}
|