Skip to content

Cleanups postgres connections logic#456

Open
kunrex wants to merge 8 commits intosdslabs:bl4ze/devfrom
kunrex:cleanup-postgres
Open

Cleanups postgres connections logic#456
kunrex wants to merge 8 commits intosdslabs:bl4ze/devfrom
kunrex:cleanup-postgres

Conversation

@kunrex
Copy link
Copy Markdown

@kunrex kunrex commented Mar 26, 2026

TLDR

Relied a lot on exec to terminate connections which wasn't preferable in the long run and especially when containerisation has to be done.

there are things that cannot be done without exec: specifically: pg_dump and pg_restore so those will have to be installed.

@kunrex kunrex requested a review from sukhman-sukh April 1, 2026 19:02
Comment thread cmd/beast/init.go
log.Infoln("Attempting to connect to postgres as postgres super user...")

dsn := fmt.Sprintf("user=%s dbname=%s sslmode=%s", "postgres", "postgres", "disable")
dsn := fmt.Sprintf("user=%s dbname=%s host=%s port=%s sslmode=%s", "postgres", "postgres", configuration.Host, configuration.Port, "disable")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add user adn dbname from config too

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is intended, at this point the db and user dont exist, so have to connect to postgres database as postgres first to create them.

Comment thread cmd/beast/init.go
password := utils.PromptSecret("Enter postgres super user password (leave blank if none):")

dsn := fmt.Sprintf("user=%s password=%s dbname=%s sslmode=%s", "postgres", password, "postgres", "disable")
dsn := fmt.Sprintf("user=%s password=%s dbname=%s host=%s port=%s sslmode=%s", "postgres", password, "postgres", configuration.Host, configuration.Port, "disable")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment thread core/database/database.go Outdated
"--if-exists",
backupFile,
)
backupFile)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix formatting

@sukhman-sukh
Copy link
Copy Markdown
Collaborator

REST LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants