This commit is contained in:
@@ -9,10 +9,11 @@ RUN touch ~app/.zshrc ~root/.zshrc; chown app:app ~app/.zshrc
|
|||||||
RUN mkdir /app
|
RUN mkdir /app
|
||||||
ADD dist/data-api_linux_amd64_v1/data-api /app/
|
ADD dist/data-api_linux_amd64_v1/data-api /app/
|
||||||
|
|
||||||
EXPOSE 4200
|
EXPOSE 8030 # app
|
||||||
EXPOSE 4290
|
EXPOSE 9019 # health
|
||||||
|
EXPOSE 9020 # metrics
|
||||||
|
|
||||||
USER app
|
USER app
|
||||||
|
|
||||||
# Container start command for production
|
# Container start command for production
|
||||||
CMD ["/app/data-api"]
|
CMD ["/app/data-api", "server"]
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import (
|
|||||||
"golang.org/x/exp/slog"
|
"golang.org/x/exp/slog"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
|
"go.ntppool.org/common/health"
|
||||||
|
"go.ntppool.org/common/logger"
|
||||||
"go.ntppool.org/common/metricsserver"
|
"go.ntppool.org/common/metricsserver"
|
||||||
|
|
||||||
chdb "go.ntppool.org/data-api/chdb"
|
chdb "go.ntppool.org/data-api/chdb"
|
||||||
@@ -56,7 +58,7 @@ func NewServer(ctx context.Context) (*Server, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) Run() error {
|
func (srv *Server) Run() error {
|
||||||
slog.Info("Run()")
|
log := logger.Setup()
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(srv.ctx)
|
ctx, cancel := context.WithCancel(srv.ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@@ -64,7 +66,11 @@ func (srv *Server) Run() error {
|
|||||||
g, _ := errgroup.WithContext(ctx)
|
g, _ := errgroup.WithContext(ctx)
|
||||||
|
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
return srv.metrics.ListenAndServe(ctx, 9000)
|
return srv.metrics.ListenAndServe(ctx, 9020)
|
||||||
|
})
|
||||||
|
|
||||||
|
g.Go(func() error {
|
||||||
|
return health.HealthCheckListener(ctx, 9019, log.WithGroup("health"))
|
||||||
})
|
})
|
||||||
|
|
||||||
e := echo.New()
|
e := echo.New()
|
||||||
@@ -84,7 +90,7 @@ func (srv *Server) Run() error {
|
|||||||
e.GET("/api/server/dns/answers/:server", srv.dnsAnswers)
|
e.GET("/api/server/dns/answers/:server", srv.dnsAnswers)
|
||||||
|
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
return e.Start(":8000")
|
return e.Start(":8030")
|
||||||
})
|
})
|
||||||
|
|
||||||
return g.Wait()
|
return g.Wait()
|
||||||
|
|||||||
Reference in New Issue
Block a user