Поддержка 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:
app:
build: .
image: registry.gitlab.com/elyby/skinsystem:latest
image: registry.ely.by/elyby/skinsystem:latest
ports:
- "80:80"
volumes:

View File

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

View File

@ -1,6 +1,7 @@
package main
import (
"os"
"log"
"runtime"
"time"
@ -16,17 +17,20 @@ import (
"elyby/minecraft-skinsystem/lib/worker"
)
const redisString string = "redis:6379"
const redisPoolSize int = 10
const rabbitmqString string = "amqp://ely-skinsystem-app:ely-skinsystem-app-password@rabbitmq:5672/%2fely"
func main() {
log.Println("Starting...")
runtime.GOMAXPROCS(runtime.NumCPU())
log.Println("Connecting to redis")
var redisString = os.Getenv("REDIS_ADDR")
if (redisString == "") {
redisString = "redis:6379"
}
redisPool, redisErr := pool.New("tcp", redisString, redisPoolSize)
if (redisErr != nil) {
log.Fatal("Redis unavailable")
@ -35,6 +39,12 @@ func main() {
log.Println("Connecting to 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)
if (rabbitmqErr != nil) {
log.Fatalf("%s", rabbitmqErr)