From 81f5ffcc2381c368e75955fe45e22a5c2e4714b4 Mon Sep 17 00:00:00 2001 From: Marcin Kaciuba Date: Mon, 24 Sep 2018 10:06:37 +0200 Subject: [PATCH] feat (go): update golang version, add hostname and pid to log --- Dockerfile | 5 ++--- cmd/mort/mort.go | 13 ++++++++++++- pkg/lock/memory.go | 7 ++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 83241ca..afe0ecf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,7 @@ FROM ubuntu:16.04 as builder ENV LIBVIPS_VERSION 8.6.2 ENV DEP_VERSION v0.4.1 -ENV GOLANG_VERSION 1.10 - +ENV GOLANG_VERSION 1.11 # Installs libvips + required libraries RUN \ @@ -15,7 +14,7 @@ RUN \ swig libmagickwand-dev libpango1.0-dev libmatio-dev libopenslide-dev libcfitsio-dev \ libgsf-1-dev fftw3-dev liborc-0.4-dev librsvg2-dev && \ cd /tmp && \ - curl -OL https://github.com/jcupitt/libvips/releases/download/v${LIBVIPS_VERSION}/vips-${LIBVIPS_VERSION}.tar.gz && \ + curl -OL https://github.com/libvips/libvips/releases/download/v${LIBVIPS_VERSION}/vips-${LIBVIPS_VERSION}.tar.gz && \ tar zvxf vips-${LIBVIPS_VERSION}.tar.gz && \ cd /tmp/vips-${LIBVIPS_VERSION} && \ ./configure --enable-debug=no --without-python $1 && \ diff --git a/cmd/mort/mort.go b/cmd/mort/mort.go index 74cd15c..d5c6279 100644 --- a/cmd/mort/mort.go +++ b/cmd/mort/mort.go @@ -20,13 +20,13 @@ import ( "github.com/aldor007/mort/pkg/throttler" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" + "go.uber.org/zap/zapcore" "net" "os" "os/signal" "strings" "sync" "syscall" - "go.uber.org/zap/zapcore" ) const ( @@ -96,6 +96,17 @@ func configureMonitoring(mortConfig *config.Config) { logCfg.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder logger, _ := logCfg.Build() + host, err := os.Hostname() + if err != nil { + host = "unknown" + } + + pid := os.Getpid() + logger = logger.With( + zap.String("hostname", host), + zap.Int("pid", pid), + ) + zap.ReplaceGlobals(logger) monitoring.RegisterLogger(logger) if mortConfig.Server.Monitoring == "prometheus" { diff --git a/pkg/lock/memory.go b/pkg/lock/memory.go index dbc676d..5ef63c0 100644 --- a/pkg/lock/memory.go +++ b/pkg/lock/memory.go @@ -1,10 +1,10 @@ package lock import ( - "github.com/aldor007/mort/pkg/monitoring" "github.com/aldor007/mort/pkg/response" - "go.uber.org/zap" "sync" + "go.uber.org/zap" + "github.com/aldor007/mort/pkg/monitoring" ) // MemoryLock is in memory lock for single mort instance @@ -33,10 +33,11 @@ func (m *MemoryLock) NotifyAndRelease(key string, res *response.Response) { m.lock.Unlock() if len(result.notifyQueue) == 0 { - monitoring.Log().Warn("Empty notify queue", zap.String("key", key)) return } + monitoring.Log().Warn("Notify queue", zap.String("key", key), zap.Int("len", len(result.notifyQueue))) + if res.IsBuffered() { resCopy, err := res.Copy() if err != nil {