Skip to content

Commit

Permalink
feat (go): update golang version, add hostname and pid to log
Browse files Browse the repository at this point in the history
  • Loading branch information
aldor007 committed Sep 24, 2018
1 parent 86a3cd3 commit 81f5ffc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 && \
Expand Down
13 changes: 12 additions & 1 deletion cmd/mort/mort.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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" {
Expand Down
7 changes: 4 additions & 3 deletions pkg/lock/memory.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 81f5ffc

Please sign in to comment.