Skip to content

Commit

Permalink
Merge branch 'main' into feature/roundingcensus_integration
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmenendez authored Jan 10, 2024
2 parents ac66005 + 3f292e4 commit 4bf8c1f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM golang:1.21.1 AS builder

WORKDIR /src
COPY . .
RUN go build -o=census3 -ldflags="-s -w" ./cmd/census3
RUN go build -o=census3 -ldflags="-s -w -X=github.com/vocdoni/census3/internal.Version=$(git describe --always --tags --dirty --match='v[0-9]*')" ./cmd/census3

FROM debian:bookworm-slim

Expand Down
3 changes: 3 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func Init(db *db.DB, conf Census3APIConf) (*census3API, error) {
if err = r.Init(conf.Hostname, conf.Port); err != nil {
return nil, err
}
// expose metrics endpoint
r.ExposePrometheusEndpoint("/metrics")

// init API using the http router created
if newAPI.endpoint, err = api.NewAPI(&r, "/api"); err != nil {
return nil, err
Expand Down
6 changes: 6 additions & 0 deletions cmd/census3/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ package main

import (
"context"
"fmt"
"os"
"os/signal"
"strings"
"syscall"
"time"

"github.com/VictoriaMetrics/metrics"
"github.com/google/uuid"
flag "github.com/spf13/pflag"
"github.com/spf13/viper"
"github.com/vocdoni/census3/api"
"github.com/vocdoni/census3/db"
"github.com/vocdoni/census3/internal"
"github.com/vocdoni/census3/service"
"github.com/vocdoni/census3/service/poap"
"github.com/vocdoni/census3/service/web3"
Expand Down Expand Up @@ -155,6 +158,9 @@ func main() {
ctx, cancel := context.WithCancel(context.Background())
go hc.Start(ctx)

metrics.NewCounter(fmt.Sprintf("census3_info{version=%q}",
internal.Version)).Set(1)

// wait for SIGTERM
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/vocdoni/census3
go 1.21.1

require (
github.com/VictoriaMetrics/metrics v1.24.0
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2
github.com/ethereum/go-ethereum v1.13.4
github.com/frankban/quicktest v1.14.6
Expand All @@ -25,7 +26,6 @@ require (
github.com/DataDog/zstd v1.5.2 // indirect
github.com/Jorropo/jsync v1.0.1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/VictoriaMetrics/metrics v1.24.0 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/alexbrainman/goissue34681 v0.0.0-20191006012335-3fc7a47baff5 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
Expand Down
5 changes: 5 additions & 0 deletions internal/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package internal

// Version will be replaced by a human-readable version from git in Docker
// and release builds.
var Version = "devel"

0 comments on commit 4bf8c1f

Please sign in to comment.