Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure port gets persisted to config file #52

Merged
merged 1 commit into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/flypg/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func NewNode() (*Node, error) {
}

// Stub configuration
node.PGConfig = NewConfig(node.DataDir)
node.PGConfig = NewConfig(node.DataDir, node.Port)

// Internal user
node.SUCredentials = Credentials{
Expand Down
5 changes: 4 additions & 1 deletion pkg/flypg/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type PGConfig struct {

internalConfigFilePath string
userConfigFilePath string
port int
dataDir string

internalConfig ConfigMap
Expand Down Expand Up @@ -54,9 +55,10 @@ func (c *PGConfig) UserConfigFile() string {
return c.userConfigFilePath
}

func NewConfig(dataDir string) *PGConfig {
func NewConfig(dataDir string, port int) *PGConfig {
return &PGConfig{
dataDir: dataDir,
port: port,
configFilePath: fmt.Sprintf("%s/postgresql.conf", dataDir),

internalConfigFilePath: fmt.Sprintf("%s/postgresql.internal.conf", dataDir),
Expand Down Expand Up @@ -198,6 +200,7 @@ func (c *PGConfig) SetDefaults() error {

conf := ConfigMap{
"random_page_cost": "1.1",
"port": c.port,
"shared_buffers": fmt.Sprintf("%dMB", sharedBuffersMb),
"max_connections": 300,
"max_replication_slots": 10,
Expand Down