@@ -212,6 +212,7 @@ cli_do_tmux_script_getopts(int argc, char **argv)
212212 { "sync-standbys" , required_argument , NULL , 's' },
213213 { "skip-pg-hba" , required_argument , NULL , 'S' },
214214 { "layout" , required_argument , NULL , 'l' },
215+ { "binpath" , required_argument , NULL , 'b' },
215216 { "version" , no_argument , NULL , 'V' },
216217 { "verbose" , no_argument , NULL , 'v' },
217218 { "quiet" , no_argument , NULL , 'q' },
@@ -229,6 +230,7 @@ cli_do_tmux_script_getopts(int argc, char **argv)
229230 options .skipHBA = false;
230231 strlcpy (options .root , "/tmp/pgaf/tmux" , sizeof (options .root ));
231232 strlcpy (options .layout , "even-vertical" , sizeof (options .layout ));
233+ strlcpy (options .binpath , pg_autoctl_argv0 , sizeof (options .binpath ));
232234
233235 if (!parseCandidatePriorities ("" , options .priorities ))
234236 {
@@ -345,6 +347,13 @@ cli_do_tmux_script_getopts(int argc, char **argv)
345347 break ;
346348 }
347349
350+ case 'b' :
351+ {
352+ strlcpy (options .binpath , optarg , MAXPGPATH );
353+ log_trace ("--binpath %s" , options .binpath );
354+ break ;
355+ }
356+
348357 case 'h' :
349358 {
350359 commandline_help (stderr );
@@ -406,6 +415,7 @@ cli_do_tmux_script_getopts(int argc, char **argv)
406415 exit (EXIT_CODE_BAD_ARGS );
407416 }
408417
418+
409419 if (errors > 0 )
410420 {
411421 commandline_help (stderr );
@@ -622,6 +632,7 @@ tmux_add_new_session(PQExpBuffer script, const char *root, int pgport)
622632void
623633tmux_pg_autoctl_create_monitor (PQExpBuffer script ,
624634 const char * root ,
635+ const char * binpath ,
625636 int pgport ,
626637 bool skipHBA )
627638{
@@ -637,7 +648,7 @@ tmux_pg_autoctl_create_monitor(PQExpBuffer script,
637648
638649 tmux_add_send_keys_command (script ,
639650 "%s create monitor %s --run" ,
640- pg_autoctl_argv0 ,
651+ binpath ,
641652 pg_ctl_opts );
642653}
643654
@@ -649,6 +660,7 @@ tmux_pg_autoctl_create_monitor(PQExpBuffer script,
649660void
650661tmux_pg_autoctl_create_postgres (PQExpBuffer script ,
651662 const char * root ,
663+ const char * binpath ,
652664 int pgport ,
653665 const char * name ,
654666 bool replicationQuorum ,
@@ -665,7 +677,7 @@ tmux_pg_autoctl_create_postgres(PQExpBuffer script,
665677
666678 sformat (monitor , sizeof (monitor ),
667679 "$(%s show uri --pgdata %s/monitor --formation monitor)" ,
668- pg_autoctl_argv0 ,
680+ binpath ,
669681 root );
670682
671683 tmux_add_send_keys_command (script ,
@@ -681,7 +693,7 @@ tmux_pg_autoctl_create_postgres(PQExpBuffer script,
681693 "--replication-quorum %s "
682694 "--candidate-priority %d "
683695 "--run" ,
684- pg_autoctl_argv0 ,
696+ binpath ,
685697 pg_ctl_opts ,
686698 monitor ,
687699 name ,
@@ -712,7 +724,8 @@ prepare_tmux_script(TmuxOptions *options, PQExpBuffer script)
712724
713725 /* start a monitor */
714726 (void ) tmux_add_xdg_environment (script );
715- tmux_pg_autoctl_create_monitor (script , root , pgport ++ , options -> skipHBA );
727+ tmux_pg_autoctl_create_monitor (script , root , options -> binpath , pgport ++ ,
728+ options -> skipHBA );
716729
717730 /* start the Postgres nodes, using the monitor URI */
718731 sformat (previousName , sizeof (previousName ), "monitor" );
@@ -733,12 +746,13 @@ prepare_tmux_script(TmuxOptions *options, PQExpBuffer script)
733746 tmux_add_send_keys_command (script ,
734747 "PG_AUTOCTL_DEBUG=1 "
735748 "%s do tmux wait --root %s %s" ,
736- pg_autoctl_argv0 ,
749+ options -> binpath ,
737750 options -> root ,
738751 previousName );
739752
740753 tmux_pg_autoctl_create_postgres (script ,
741754 root ,
755+ options -> binpath ,
742756 node -> pgport ,
743757 node -> name ,
744758 node -> replicationQuorum ,
@@ -757,12 +771,12 @@ prepare_tmux_script(TmuxOptions *options, PQExpBuffer script)
757771 tmux_add_send_keys_command (script ,
758772 "PG_AUTOCTL_DEBUG=1 "
759773 "%s do tmux wait --root %s %s" ,
760- pg_autoctl_argv0 ,
774+ options -> binpath ,
761775 options -> root ,
762776 "monitor" );
763777 tmux_add_send_keys_command (script ,
764778 "watch -n 0.2 %s show state" ,
765- pg_autoctl_argv0 );
779+ options -> binpath );
766780
767781 /* add a window for interactive pg_autoctl commands */
768782 tmux_add_command (script , "split-window -v" );
@@ -785,15 +799,15 @@ prepare_tmux_script(TmuxOptions *options, PQExpBuffer script)
785799 tmux_add_send_keys_command (script ,
786800 "PG_AUTOCTL_DEBUG=1 "
787801 "%s do tmux wait --root %s %s %s" ,
788- pg_autoctl_argv0 ,
802+ options -> binpath ,
789803 options -> root ,
790804 firstNode ,
791805 NodeStateToString (targetPrimaryState ));
792806
793807 /* PGDATA has just been exported, rely on it */
794808 tmux_add_send_keys_command (script ,
795809 "%s set formation number-sync-standbys %d" ,
796- pg_autoctl_argv0 ,
810+ options -> binpath ,
797811 options -> numSync );
798812 }
799813
0 commit comments