mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
move environment to run in into .env file
This commit is contained in:
parent
8b87b89e5d
commit
0ac448a9ba
2 changed files with 5 additions and 10 deletions
|
@ -20,4 +20,4 @@ RUN go get -d -v ./...
|
||||||
RUN go build ./cmd/nourybot
|
RUN go build ./cmd/nourybot
|
||||||
|
|
||||||
# Run the executable
|
# Run the executable
|
||||||
CMD [ "./nourybot", "env='prod'" ]
|
CMD [ "./nourybot" ]
|
||||||
|
|
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
@ -26,6 +25,7 @@ type config struct {
|
||||||
twitchClientSecret string
|
twitchClientSecret string
|
||||||
twitchID string
|
twitchID string
|
||||||
commandPrefix string
|
commandPrefix string
|
||||||
|
env string
|
||||||
db struct {
|
db struct {
|
||||||
dsn string
|
dsn string
|
||||||
maxOpenConns int
|
maxOpenConns int
|
||||||
|
@ -44,12 +44,6 @@ type application struct {
|
||||||
// Rdb *redis.Client
|
// Rdb *redis.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
var envFlag string
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
flag.StringVar(&envFlag, "env", "prod", "database connection to use: (dev/prod)")
|
|
||||||
flag.Parse()
|
|
||||||
}
|
|
||||||
func main() {
|
func main() {
|
||||||
var cfg config
|
var cfg config
|
||||||
// Initialize a new sugared logger that we'll pass on
|
// Initialize a new sugared logger that we'll pass on
|
||||||
|
@ -76,9 +70,10 @@ func main() {
|
||||||
cfg.twitchClientSecret = os.Getenv("TWITCH_CLIENT_SECRET")
|
cfg.twitchClientSecret = os.Getenv("TWITCH_CLIENT_SECRET")
|
||||||
cfg.commandPrefix = os.Getenv("TWITCH_COMMAND_PREFIX")
|
cfg.commandPrefix = os.Getenv("TWITCH_COMMAND_PREFIX")
|
||||||
cfg.twitchID = os.Getenv("TWITCH_ID")
|
cfg.twitchID = os.Getenv("TWITCH_ID")
|
||||||
|
cfg.env = os.Getenv("ENV")
|
||||||
tc := twitch.NewClient(cfg.twitchUsername, cfg.twitchOauth)
|
tc := twitch.NewClient(cfg.twitchUsername, cfg.twitchOauth)
|
||||||
|
|
||||||
switch envFlag {
|
switch cfg.env {
|
||||||
case "dev":
|
case "dev":
|
||||||
cfg.db.dsn = os.Getenv("DEV_DSN")
|
cfg.db.dsn = os.Getenv("DEV_DSN")
|
||||||
case "prod":
|
case "prod":
|
||||||
|
@ -188,7 +183,7 @@ func main() {
|
||||||
// Successfully connected to Twitch
|
// Successfully connected to Twitch
|
||||||
app.Log.Infow("Successfully connected to Twitch Servers",
|
app.Log.Infow("Successfully connected to Twitch Servers",
|
||||||
"Bot username", cfg.twitchUsername,
|
"Bot username", cfg.twitchUsername,
|
||||||
"Environment", envFlag,
|
"Environment", cfg.env,
|
||||||
"Database Open Conns", cfg.db.maxOpenConns,
|
"Database Open Conns", cfg.db.maxOpenConns,
|
||||||
"Database Idle Conns", cfg.db.maxIdleConns,
|
"Database Idle Conns", cfg.db.maxIdleConns,
|
||||||
"Database Idle Time", cfg.db.maxIdleTime,
|
"Database Idle Time", cfg.db.maxIdleTime,
|
||||||
|
|
Loading…
Reference in a new issue