Fix issue with upgrading to postgres 12 docker image #36

This commit is contained in:
Vikram Rangnekar 2020-02-24 02:37:21 +05:30
parent be5d4e976a
commit 7acf28bb3c
5 changed files with 271 additions and 257 deletions

View File

@ -35,7 +35,7 @@ $(GORICE):
$(WEB_BUILD_DIR): $(WEB_BUILD_DIR):
@echo "First install Yarn and create a build of the web UI found under ./web" @echo "First install Yarn and create a build of the web UI found under ./web"
@echo "Command: cd web && yarn build" @echo "Command: cd web && yarn && yarn build"
@exit 1 @exit 1
$(GITCHGLOG): $(GITCHGLOG):
@ -77,7 +77,7 @@ clean:
run: clean run: clean
@go run $(BUILD_FLAGS) main.go $(ARGS) @go run $(BUILD_FLAGS) main.go $(ARGS)
install: install: gen
@echo $(GOPATH) @echo $(GOPATH)
@echo "Commit Hash: `git rev-parse HEAD`" @echo "Commit Hash: `git rev-parse HEAD`"
@echo "Old Hash: `shasum $(GOPATH)/bin/$(BINARY) 2>/dev/null | cut -c -32`" @echo "Old Hash: `shasum $(GOPATH)/bin/$(BINARY) 2>/dev/null | cut -c -32`"

View File

@ -2,11 +2,11 @@ version: '3.4'
services: services:
db: db:
image: postgres:12 image: postgres:12
ports:
- "5432:5432"
environment: environment:
POSTGRES_USER: postgres POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"
# redis: # redis:
# image: redis:alpine # image: redis:alpine

View File

@ -5,6 +5,7 @@ import (
"crypto/sha256" "crypto/sha256"
"fmt" "fmt"
"os" "os"
"time"
"github.com/dosco/super-graph/allow" "github.com/dosco/super-graph/allow"
"github.com/dosco/super-graph/crypto" "github.com/dosco/super-graph/crypto"
@ -135,7 +136,17 @@ func initDBPool(c *config) (*pgxpool.Pool, error) {
config.MaxConns = conf.DB.PoolSize config.MaxConns = conf.DB.PoolSize
} }
db, err := pgxpool.ConnectConfig(context.Background(), config) var db *pgxpool.Pool
var err error
for i := 1; i < 10; i++ {
db, err = pgxpool.ConnectConfig(context.Background(), config)
if err == nil {
break
}
time.Sleep(time.Duration(i*100) * time.Millisecond)
}
if err != nil { if err != nil {
return nil, err return nil, err
} }

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,10 @@ version: '3.4'
services: services:
# Postgres DB # Postgres DB
db: db:
image: postgres:11.5 image: postgres:12
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports: ports:
- "5432:5432" - "5432:5432"