Поддержка env для подключения к внешним контейнерам

This commit is contained in:
ErickSkrauch 2016-10-12 20:43:10 +03:00
parent 9c4930a0be
commit e05c5f200c
3 changed files with 15 additions and 5 deletions

View File

@ -2,7 +2,7 @@ version: '2'
services: services:
app: app:
build: . build: .
image: registry.gitlab.com/elyby/skinsystem:latest image: registry.ely.by/elyby/skinsystem:latest
ports: ports:
- "80:80" - "80:80"
volumes: volumes:

View File

@ -1,7 +1,7 @@
version: '2' version: '2'
services: services:
app: app:
image: registry.gitlab.com/elyby/skinsystem:latest image: registry.ely.by/elyby/skinsystem:latest
ports: ports:
- "80:80" - "80:80"
links: links:

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"os"
"log" "log"
"runtime" "runtime"
"time" "time"
@ -16,17 +17,20 @@ import (
"elyby/minecraft-skinsystem/lib/worker" "elyby/minecraft-skinsystem/lib/worker"
) )
const redisString string = "redis:6379"
const redisPoolSize int = 10 const redisPoolSize int = 10
const rabbitmqString string = "amqp://ely-skinsystem-app:ely-skinsystem-app-password@rabbitmq:5672/%2fely"
func main() { func main() {
log.Println("Starting...") log.Println("Starting...")
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())
log.Println("Connecting to redis") log.Println("Connecting to redis")
var redisString = os.Getenv("REDIS_ADDR")
if (redisString == "") {
redisString = "redis:6379"
}
redisPool, redisErr := pool.New("tcp", redisString, redisPoolSize) redisPool, redisErr := pool.New("tcp", redisString, redisPoolSize)
if (redisErr != nil) { if (redisErr != nil) {
log.Fatal("Redis unavailable") log.Fatal("Redis unavailable")
@ -35,6 +39,12 @@ func main() {
log.Println("Connecting to rabbitmq") log.Println("Connecting to rabbitmq")
// TODO: rabbitmq становится доступен не сразу. Нужно дождаться, пока он станет доступен, периодически повторяя запросы // TODO: rabbitmq становится доступен не сразу. Нужно дождаться, пока он станет доступен, периодически повторяя запросы
var rabbitmqString = os.Getenv("RABBITMQ_ADDR")
if (rabbitmqString == "") {
rabbitmqString = "amqp://ely-skinsystem-app:ely-skinsystem-app-password@rabbitmq:5672/%2fely"
}
rabbitConnection, rabbitmqErr := amqp.Dial(rabbitmqString) rabbitConnection, rabbitmqErr := amqp.Dial(rabbitmqString)
if (rabbitmqErr != nil) { if (rabbitmqErr != nil) {
log.Fatalf("%s", rabbitmqErr) log.Fatalf("%s", rabbitmqErr)