mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add env flag for database connection
This commit is contained in:
parent
0ff77d63b3
commit
e2a4e32dae
1 changed files with 14 additions and 4 deletions
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
@ -41,6 +42,13 @@ type Application struct {
|
||||||
Scheduler *cron.Cron
|
Scheduler *cron.Cron
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var envFlag string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
flag.StringVar(&envFlag, "env", "dev", "database connection to use: (dev/prod)")
|
||||||
|
flag.Parse()
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var cfg config
|
var cfg config
|
||||||
|
|
||||||
|
@ -62,11 +70,13 @@ func main() {
|
||||||
cfg.commandPrefix = os.Getenv("TWITCH_COMMAND_PREFIX")
|
cfg.commandPrefix = os.Getenv("TWITCH_COMMAND_PREFIX")
|
||||||
tc := twitch.NewClient(cfg.twitchUsername, cfg.twitchOauth)
|
tc := twitch.NewClient(cfg.twitchUsername, cfg.twitchOauth)
|
||||||
|
|
||||||
// Will be used someday Copesen
|
switch envFlag {
|
||||||
cfg.environment = "Development"
|
case "dev":
|
||||||
|
cfg.db.dsn = os.Getenv("LOCAL_DSN")
|
||||||
|
case "prod":
|
||||||
|
cfg.db.dsn = os.Getenv("SUPABASE_DSN")
|
||||||
|
}
|
||||||
// Database config variables
|
// Database config variables
|
||||||
cfg.db.dsn = os.Getenv("DB_DSN")
|
|
||||||
cfg.db.maxOpenConns = 25
|
cfg.db.maxOpenConns = 25
|
||||||
cfg.db.maxIdleConns = 25
|
cfg.db.maxIdleConns = 25
|
||||||
cfg.db.maxIdleTime = "15m"
|
cfg.db.maxIdleTime = "15m"
|
||||||
|
|
Loading…
Reference in a new issue