Migrating string to env variable for containerization
This commit is contained in:
parent
5ff1519689
commit
1fb2577dcb
@ -6,15 +6,6 @@ import (
|
||||
"muzzammil.xyz/jsonc"
|
||||
)
|
||||
|
||||
// Database - Database configuration used by config.go
|
||||
type Database struct {
|
||||
Host string `"json:host"`
|
||||
Port int `"json:port"`
|
||||
Username string `"json:username"`
|
||||
Password string `"json:password"`
|
||||
Workers int `"json:workers"`
|
||||
}
|
||||
|
||||
// MassFollower - Mass follower configuration used by config.go
|
||||
type MassFollower struct {
|
||||
Acct string `"json:acct"`
|
||||
@ -49,7 +40,6 @@ type Settings struct {
|
||||
Proxies []Proxy `"json:proxies"`
|
||||
Externalaccounts []ExtAccount `"json:externalaccounts"`
|
||||
MassFollowers []MassFollower `"json:massfollowers"`
|
||||
Database Database `"json:database"`
|
||||
LogLevel int `"json:loglevel"`
|
||||
}
|
||||
|
||||
|
@ -80,15 +80,6 @@
|
||||
}
|
||||
],
|
||||
|
||||
// Requires a postgres database
|
||||
"database": {
|
||||
"host": "127.0.0.1",
|
||||
"port": 5432,
|
||||
"username": "fedilogue",
|
||||
"password": "",
|
||||
"workers": 4
|
||||
},
|
||||
|
||||
/*
|
||||
Log Level:
|
||||
* 0 = No logs
|
||||
|
@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/jackc/pgx/v4/pgxpool"
|
||||
)
|
||||
|
||||
@ -10,8 +10,7 @@ var pool *pgxpool.Pool
|
||||
|
||||
func getDbPool() *pgxpool.Pool {
|
||||
// Setup Database
|
||||
dbURI := fmt.Sprintf("postgres://%s:%s@%s:%d/fedilogue", settings.Database.Username, settings.Database.Password, settings.Database.Host, settings.Database.Port)
|
||||
pool, err := pgxpool.Connect(context.Background(), dbURI)
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("DATABASE_URL"))
|
||||
if err != nil {
|
||||
logFatal.Fatal("Unable to connect to database:", err)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user