Prashant Shahi 48ac20885f
refactor(query-service): ♻️ Update ldflags and Makefile for dynamic versioning (#655)
* refactor(query-service): ♻️  Update ldflags and Makefile for dynamic versioning

Signed-off-by: Prashant Shahi <prashant@signoz.io>

* chore: 🎨 Use blacnk spaces indentation in build details

* chore(query-service): 🎨  small build details format changes

* refactor(query-service): ♻️ refactor ldflags for go build
2022-02-01 23:03:16 +05:30

67 lines
1.6 KiB
Go

package main
import (
"os"
"os/signal"
"syscall"
_ "github.com/golang-migrate/migrate/v4/database/postgres"
_ "github.com/golang-migrate/migrate/v4/source/github"
"go.signoz.io/query-service/app"
"go.signoz.io/query-service/constants"
"go.signoz.io/query-service/version"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
func initZapLog() *zap.Logger {
config := zap.NewDevelopmentConfig()
config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
config.EncoderConfig.TimeKey = "timestamp"
config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
logger, _ := config.Build()
return logger
}
func main() {
loggerMgr := initZapLog()
zap.ReplaceGlobals(loggerMgr)
defer loggerMgr.Sync() // flushes buffer, if any
logger := loggerMgr.Sugar()
version.PrintVersion()
serverOptions := &app.ServerOptions{
// HTTPHostPort: v.GetString(app.HTTPHostPort),
// DruidClientUrl: v.GetString(app.DruidClientUrl),
HTTPHostPort: constants.HTTPHostPort,
// DruidClientUrl: constants.DruidClientUrl,
}
server, err := app.NewServer(serverOptions)
if err != nil {
logger.Fatal("Failed to create server", zap.Error(err))
}
if err := server.Start(); err != nil {
logger.Fatal("Could not start servers", zap.Error(err))
}
signalsChannel := make(chan os.Signal, 1)
signal.Notify(signalsChannel, os.Interrupt, syscall.SIGTERM)
for {
select {
case status := <-server.HealthCheckStatus():
logger.Info("Received HealthCheck status: ", zap.Int("status", int(status)))
case <-signalsChannel:
logger.Fatal("Received OS Interrupt Signal ... ")
}
}
}