@@ -234,15 +234,19 @@ keeper_cli_pgsetup_pg_ctl(int argc, char **argv)
234234void
235235keeper_cli_pgsetup_discover (int argc , char * * argv )
236236{
237- bool missingPgdataOk = true;
238- PostgresSetup pgSetup = { 0 };
237+ ConfigFilePaths pathnames = { 0 };
238+ LocalPostgresServer postgres = { 0 };
239+ PostgresSetup * pgSetup = & (postgres .postgresSetup );
239240
240- if (!pg_setup_init ( & pgSetup , & keeperOptions . pgSetup , true, true ))
241+ if (!cli_common_pgsetup_init ( & pathnames , pgSetup ))
241242 {
242- exit (EXIT_CODE_PGCTL );
243+ /* errors have already been logged */
244+ exit (EXIT_CODE_BAD_CONFIG );
243245 }
244246
245- if (!pg_controldata (& pgSetup , missingPgdataOk ))
247+ bool missingPgdataOk = true;
248+
249+ if (!pg_controldata (pgSetup , missingPgdataOk ))
246250 {
247251 exit (EXIT_CODE_PGCTL );
248252 }
@@ -252,7 +256,7 @@ keeper_cli_pgsetup_discover(int argc, char **argv)
252256 fformat (stdout , "Node Name: %s\n" , keeperOptions .hostname );
253257 }
254258
255- fprintf_pg_setup (stdout , & pgSetup );
259+ fprintf_pg_setup (stdout , pgSetup );
256260}
257261
258262
@@ -263,19 +267,22 @@ keeper_cli_pgsetup_discover(int argc, char **argv)
263267void
264268keeper_cli_pgsetup_is_ready (int argc , char * * argv )
265269{
266- PostgresSetup pgSetup = { 0 };
267- bool pgIsNotRunningIsOk = false;
270+ ConfigFilePaths pathnames = { 0 };
271+ LocalPostgresServer postgres = { 0 };
272+ PostgresSetup * pgSetup = & (postgres .postgresSetup );
268273
269- if (!pg_setup_init ( & pgSetup , & keeperOptions . pgSetup , true, true ))
274+ if (!cli_common_pgsetup_init ( & pathnames , pgSetup ))
270275 {
271- exit (EXIT_CODE_PGCTL );
276+ /* errors have already been logged */
277+ exit (EXIT_CODE_BAD_CONFIG );
272278 }
273279
274280 log_debug ("Initialized pgSetup, now calling pg_setup_is_ready()" );
275281
276- bool pgIsReady = pg_setup_is_ready (& pgSetup , pgIsNotRunningIsOk );
282+ bool pgIsNotRunningIsOk = false;
283+ bool pgIsReady = pg_setup_is_ready (pgSetup , pgIsNotRunningIsOk );
277284
278- log_info ("Postgres status is: \"%s\"" , pmStatusToString (pgSetup . pm_status ));
285+ log_info ("Postgres status is: \"%s\"" , pmStatusToString (pgSetup -> pm_status ));
279286
280287 if (pgIsReady )
281288 {
@@ -293,18 +300,22 @@ void
293300keeper_cli_pgsetup_wait_until_ready (int argc , char * * argv )
294301{
295302 int timeout = 30 ;
296- PostgresSetup pgSetup = { 0 };
297303
298- if (!pg_setup_init (& pgSetup , & keeperOptions .pgSetup , true, true))
304+ ConfigFilePaths pathnames = { 0 };
305+ LocalPostgresServer postgres = { 0 };
306+ PostgresSetup * pgSetup = & (postgres .postgresSetup );
307+
308+ if (!cli_common_pgsetup_init (& pathnames , pgSetup ))
299309 {
300- exit (EXIT_CODE_PGCTL );
310+ /* errors have already been logged */
311+ exit (EXIT_CODE_BAD_CONFIG );
301312 }
302313
303314 log_debug ("Initialized pgSetup, now calling pg_setup_wait_until_is_ready()" );
304315
305- bool pgIsReady = pg_setup_wait_until_is_ready (& pgSetup , timeout , LOG_INFO );
316+ bool pgIsReady = pg_setup_wait_until_is_ready (pgSetup , timeout , LOG_INFO );
306317
307- log_info ("Postgres status is: \"%s\"" , pmStatusToString (pgSetup . pm_status ));
318+ log_info ("Postgres status is: \"%s\"" , pmStatusToString (pgSetup -> pm_status ));
308319
309320 if (pgIsReady )
310321 {
@@ -320,16 +331,19 @@ keeper_cli_pgsetup_wait_until_ready(int argc, char **argv)
320331void
321332keeper_cli_pgsetup_startup_logs (int argc , char * * argv )
322333{
323- PostgresSetup pgSetup = { 0 };
334+ ConfigFilePaths pathnames = { 0 };
335+ LocalPostgresServer postgres = { 0 };
336+ PostgresSetup * pgSetup = & (postgres .postgresSetup );
324337
325- if (!pg_setup_init ( & pgSetup , & keeperOptions . pgSetup , true, true ))
338+ if (!cli_common_pgsetup_init ( & pathnames , pgSetup ))
326339 {
327- exit (EXIT_CODE_PGCTL );
340+ /* errors have already been logged */
341+ exit (EXIT_CODE_BAD_CONFIG );
328342 }
329343
330344 log_debug ("Initialized pgSetup, now calling pg_log_startup()" );
331345
332- if (!pg_log_startup (pgSetup . pgdata , LOG_INFO ))
346+ if (!pg_log_startup (pgSetup -> pgdata , LOG_INFO ))
333347 {
334348 exit (EXIT_CODE_PGCTL );
335349 }
0 commit comments