Permalink
Browse files

fix #53: use custom database; improve smoke demo

  • Loading branch information...
kamilsk committed Jan 7, 2019
1 parent 940b9c1 commit f4c676e3f499927d31170c10a557391a8ccb68af
@@ -24,7 +24,7 @@ var (
"write_timeout": time.Duration(0),
"idle_timeout": time.Duration(0),
"base_url": "http://localhost:8080/",
"dsn": "postgres://postgres:postgres@127.0.0.1:5432/postgres?connect_timeout=1&sslmode=disable",
"dsn": "postgres://passport:passport@127.0.0.1:5432/passport?connect_timeout=1&sslmode=disable",
"open_conn": 1,
"idle_conn": 1,
"conn_max_lt": 0,
@@ -42,7 +42,7 @@ BASE_URL=https://127.0.0.1.xip.io/

PASSPORT_TOKEN=10000000-2000-4000-8000-160000000003

DB_DSN=postgres://postgres:postgres@db:5432/postgres?connect_timeout=1&sslmode=disable
DB_DSN=postgres://passport:passport@db:5432/passport?connect_timeout=1&sslmode=disable
DB_OPEN_CONN=1
DB_IDLE_CONN=1
DB_CONN_MAX_LT=0
@@ -5,6 +5,8 @@ services:
db:
image: postgres:10-alpine # https://hub.docker.com/_/postgres/
env_file: ../../.env
volumes:
- ../db/initdb.d:/docker-entrypoint-initdb.d

migration:
image: kamilsk/passport:1.x # https://hub.docker.com/r/kamilsk/passport/
@@ -1,11 +1,3 @@
version: "3"

services:

db: {}

migration: {}

service: {}

server: {}
services: {}
@@ -1,11 +1,3 @@
version: "3"

services:

db: {}

migration: {}

service: {}

server: {}
services: {}
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -e

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE USER "passport" WITH PASSWORD 'passport';
CREATE DATABASE "passport" WITH OWNER "passport";
\c "passport";
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
EOSQL
@@ -1,8 +1,41 @@
package main

import "net/http"
import (
"fmt"
"net/http"
"os"
"os/exec"
"os/signal"
)

func main() {
stoper := exec.Command("make", "stop-service")
stoper.Stderr, stoper.Stdout = os.Stderr, os.Stdout
_ = stoper.Run()
fmt.Println("service down")

dev := exec.Command("make", "dev-server")
_ = dev.Start()
fmt.Println("dev server start")

go func() {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
<-c
{
_ = dev.Process.Kill()
fmt.Println("dev server down")

starter := exec.Command("make", "start-service")
starter.Stderr, starter.Stdout = os.Stderr, os.Stdout
_ = starter.Run()
fmt.Println("service up")
}
signal.Stop(c)
fmt.Println()
os.Exit(0)
}()

_ = http.ListenAndServe(":9000", http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
_, _ = rw.Write([]byte(`
<!doctype html>

0 comments on commit f4c676e

Please sign in to comment.