From e33f90760043bb852d093f26bd66f03e9f84920b Mon Sep 17 00:00:00 2001 From: Shaun Davis Date: Tue, 31 Jan 2023 08:41:14 -0600 Subject: [PATCH] Ensure port gets persisted to config file --- pkg/flypg/node.go | 2 +- pkg/flypg/pg.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/flypg/node.go b/pkg/flypg/node.go index 0eef839a..4ea1b63c 100644 --- a/pkg/flypg/node.go +++ b/pkg/flypg/node.go @@ -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{ diff --git a/pkg/flypg/pg.go b/pkg/flypg/pg.go index dd0b47a7..25045a73 100644 --- a/pkg/flypg/pg.go +++ b/pkg/flypg/pg.go @@ -21,6 +21,7 @@ type PGConfig struct { internalConfigFilePath string userConfigFilePath string + port int dataDir string internalConfig ConfigMap @@ -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), @@ -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,