@@ -90,7 +90,7 @@ struct TaskEnvironment {
9090 // otherwise)
9191
9292 bsl::string d_bmqPrefix;
93- // BMQ_PREFIX directory path
93+ // Directory path to store PID, HIST, and CTL files under.
9494
9595 bsl::string d_configJson;
9696 // JSON content ouput of the generated
@@ -414,7 +414,7 @@ static int initializeTask(bsl::ostream& errorDescription,
414414 bdlf::PlaceHolders::_1, // prefix
415415 bdlf::PlaceHolders::_2)); // istream
416416
417- // Save the PID of the process in the '${BMQ_PREFIX }/bmqbrkr.pid' file
417+ // Save the PID of the process in the '{prefix }/bmqbrkr.pid' file
418418 const bsl::string pidFile = taskEnv->d_bmqPrefix + " /bmqbrkr.pid" ;
419419 bsl::ofstream pidFd (pidFile.c_str ());
420420 if (!pidFd) {
@@ -499,9 +499,9 @@ static void shutdownApplication(TaskEnvironment* taskEnv)
499499 app.mqba ::Application::~Application ();
500500}
501501
502- // / Update the `bmqbrkr.hist` file (in the BMQ_PREFIX directory) using the
502+ // / Update the `bmqbrkr.hist` file (in the prefix directory) using the
503503// / specified `taskEnv`. This file contains information about the last `n`
504- // / successfull start of the broker, in reverse time order.
504+ // / successful starts of the broker, in reverse time order.
505505// / Each line entry has the following format:
506506// / <currentTime_UTC>|<brokerVersion>|<configVersion>|<brokerId>
507507// /
@@ -598,6 +598,7 @@ int main(int argc, const char* argv[])
598598{
599599 // Parse command line parameters
600600 bsl::string configDir;
601+ bsl::string prefixDir;
601602 bsl::string instanceId = " default" ;
602603 bsl::string hostName;
603604 bsl::string hostTags;
@@ -611,6 +612,11 @@ int main(int argc, const char* argv[])
611612 " Path to the configuration directory" ,
612613 balcl::TypeInfo (&configDir),
613614 balcl::OccurrenceInfo::e_REQUIRED},
615+ {" " ,
616+ " prefixDir" ,
617+ " Path to the prefix directory (where PID, HIST, and CTL files live)" ,
618+ balcl::TypeInfo (&prefixDir),
619+ balcl::OccurrenceInfo::e_OPTIONAL},
614620 {" i|instanceId" ,
615621 " instanceId" ,
616622 " The instance ID ('default' if not provided)" ,
@@ -687,8 +693,11 @@ int main(int argc, const char* argv[])
687693 TaskEnvironment taskEnv;
688694 s_taskEnv_p = &taskEnv;
689695
690- const char * prefixEnvVar = bsl::getenv (" BMQ_PREFIX" );
691- taskEnv.d_bmqPrefix = (prefixEnvVar != 0 ? prefixEnvVar : " ./" );
696+ // Default prefix directory to `BMQ_PREFIX` or ./
697+ if (prefixDir.empty ()) {
698+ prefixDir = bsl::getenv (" BMQ_PREFIX" );
699+ }
700+ taskEnv.d_bmqPrefix = (!prefixDir.empty () ? prefixDir : " ./" );
692701 taskEnv.d_instanceId = instanceId;
693702
694703 bmqu::MemOutStream errorDescription;
0 commit comments