Skip to content

Commit

Permalink
[-] do not produce db objects, use db.Ping() instead of sqlx.Connect()
Browse files Browse the repository at this point in the history
  • Loading branch information
pashagolub committed Apr 12, 2020
1 parent e4b1d8c commit 8662f94
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions internal/pgengine/bootstrap.go
Expand Up @@ -128,8 +128,7 @@ func ReconnectDbAndFixLeftovers() {
fmt.Printf(GetLogPrefixLn("REPAIR"), fmt.Sprintf("Connection to the server was lost. Waiting for %d sec...", waitTime))
time.Sleep(waitTime * time.Second)
fmt.Printf(GetLogPrefix("REPAIR"), "Reconnecting...\n")
ConfigDb, err = sqlx.Connect("postgres", fmt.Sprintf("host=%s port=%s dbname=%s sslmode=%s user=%s password=%s",
Host, Port, DbName, SSLMode, User, Password))
err = ConfigDb.Ping()
if err == nil {
LogToDB("LOG", "Connection reestablished...")
FixSchedulerCrash()
Expand Down
3 changes: 2 additions & 1 deletion internal/pgengine/log.go
Expand Up @@ -42,9 +42,10 @@ func GetLogPrefixLn(level string) string {
return GetLogPrefix(level) + "\n"
}

const logTemplate = `INSERT INTO timetable.log(pid, client_name, log_level, message) VALUES ($1, $2, $3, $4)`

// LogToDB performs logging to configuration database ConfigDB initiated during bootstrap
func LogToDB(level string, msg ...interface{}) {
const logTemplate = `INSERT INTO timetable.log(pid, client_name, log_level, message) VALUES ($1, $2, $3, $4)`
if !VerboseLogLevel {
switch level {
case
Expand Down

0 comments on commit 8662f94

Please sign in to comment.