mirror of
https://github.com/elyby/chrly.git
synced 2024-12-24 05:59:54 +05:30
Конфиг Accounts API вынесен в параметры окружения
This commit is contained in:
parent
8693673a71
commit
cbe940f8ec
@ -12,6 +12,10 @@ services:
|
|||||||
- redis
|
- redis
|
||||||
- rabbitmq
|
- rabbitmq
|
||||||
- statsd
|
- statsd
|
||||||
|
environment:
|
||||||
|
ACCOUNTS_API_ID: ""
|
||||||
|
ACCOUNTS_API_SECRET: ""
|
||||||
|
STATSD_ADDR: ""
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
extends:
|
extends:
|
||||||
|
@ -8,6 +8,10 @@ services:
|
|||||||
- redis
|
- redis
|
||||||
- rabbitmq
|
- rabbitmq
|
||||||
restart: always
|
restart: always
|
||||||
|
environment:
|
||||||
|
ACCOUNTS_API_ID: ""
|
||||||
|
ACCOUNTS_API_SECRET: ""
|
||||||
|
STATSD_ADDR: ""
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
extends:
|
extends:
|
||||||
|
@ -5,6 +5,8 @@ import (
|
|||||||
"elyby/minecraft-skinsystem/lib/external/accounts"
|
"elyby/minecraft-skinsystem/lib/external/accounts"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var AccountsTokenConfig *accounts.TokenRequest
|
||||||
|
|
||||||
var token *accounts.Token
|
var token *accounts.Token
|
||||||
|
|
||||||
const repeatsLimit = 3
|
const repeatsLimit = 3
|
||||||
@ -40,13 +42,7 @@ func _getByField(field string, value string) (accounts.AccountInfoResponse, erro
|
|||||||
|
|
||||||
func getToken() (*accounts.Token, error) {
|
func getToken() (*accounts.Token, error) {
|
||||||
if token == nil {
|
if token == nil {
|
||||||
tempToken, err := accounts.GetToken(accounts.TokenRequest{
|
tempToken, err := accounts.GetToken(*AccountsTokenConfig)
|
||||||
Id: "skinsystem",
|
|
||||||
Secret: "qugFIaCjec3LMA",
|
|
||||||
Scopes: []string{
|
|
||||||
"internal_account_info",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &accounts.Token{}, err
|
return &accounts.Token{}, err
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
"elyby/minecraft-skinsystem/lib/routes"
|
"elyby/minecraft-skinsystem/lib/routes"
|
||||||
"elyby/minecraft-skinsystem/lib/services"
|
"elyby/minecraft-skinsystem/lib/services"
|
||||||
"elyby/minecraft-skinsystem/lib/worker"
|
"elyby/minecraft-skinsystem/lib/worker"
|
||||||
|
"elyby/minecraft-skinsystem/lib/external/accounts"
|
||||||
)
|
)
|
||||||
|
|
||||||
const redisPoolSize int = 10
|
const redisPoolSize int = 10
|
||||||
@ -28,6 +29,20 @@ func main() {
|
|||||||
|
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
||||||
|
accountsApiId := os.Getenv("ACCOUNTS_API_ID")
|
||||||
|
accountsApiSecret := os.Getenv("ACCOUNTS_API_SECRET")
|
||||||
|
if accountsApiId == "" || accountsApiSecret == "" {
|
||||||
|
log.Fatal("ACCOUNTS_API params must be provided")
|
||||||
|
}
|
||||||
|
|
||||||
|
worker.AccountsTokenConfig = &accounts.TokenRequest{
|
||||||
|
Id: accountsApiId,
|
||||||
|
Secret: accountsApiSecret,
|
||||||
|
Scopes: []string{
|
||||||
|
"internal_account_info",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
log.Println("Connecting to redis")
|
log.Println("Connecting to redis")
|
||||||
|
|
||||||
var redisString = os.Getenv("REDIS_ADDR")
|
var redisString = os.Getenv("REDIS_ADDR")
|
||||||
@ -62,6 +77,7 @@ func main() {
|
|||||||
|
|
||||||
// statsd
|
// statsd
|
||||||
var statsdString = os.Getenv("STATSD_ADDR")
|
var statsdString = os.Getenv("STATSD_ADDR")
|
||||||
|
statsdString = ""
|
||||||
if (statsdString != "") {
|
if (statsdString != "") {
|
||||||
log.Println("Connecting to statsd")
|
log.Println("Connecting to statsd")
|
||||||
hostname, _ := os.Hostname()
|
hostname, _ := os.Hostname()
|
||||||
|
Loading…
Reference in New Issue
Block a user