Skip to content

Commit

Permalink
Merge pull request #17941 from jakesmith/HPCC-30628-cli-noconfig
Browse files Browse the repository at this point in the history
HPCC-30628 Add initNullConfiguration for CLI's without configuration

Reviewed-by: Gavin Halliday <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Oct 25, 2023
2 parents 951e158 + 548b104 commit 4a983bf
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
2 changes: 2 additions & 0 deletions dali/dalidiag/dalidiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ int main(int _argc, char* argv[])
}

try {
initNullConfiguration();

Owned<IGroup> group = createIGroup(epa);
assertex(group);
initClientProcess(group, DCR_DaliDiag, 0, NULL, NULL, MP_WAIT_FOREVER);
Expand Down
31 changes: 20 additions & 11 deletions dali/dalistop/dalistop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
#include "daclient.hpp"


static void usage()
{
printf("usage: dalistop <server_ip:port> [/nowait]\n");
printf("eg: dalistop . -- stop dali server running locally\n");
printf(" dalistop eq0001016 -- stop dali server running remotely\n");
}

int main(int argc, const char* argv[])
{
InitModuleObjects();
Expand All @@ -34,23 +41,25 @@ int main(int argc, const char* argv[])
const char *server = nullptr;
if (argc<2)
{
// with no args, use port from daliconfig if present (used by init scripts)
Owned<IFile> daliConfigFile = createIFile("daliconf.xml");
if (daliConfigFile->exists())
{
Owned<IPropertyTree> daliConfig = createPTree(*daliConfigFile, ipt_caseInsensitive);
port = daliConfig->getPropInt("@port", DALI_SERVER_PORT);
server = ".";
}
if (isContainerized())
usage();
else
{
printf("usage: dalistop <server_ip:port> [/nowait]\n");
printf("eg: dalistop . -- stop dali server running locally\n");
printf(" dalistop eq0001016 -- stop dali server running remotely\n");
// with no args, use port from daliconfig if present (used by init scripts)
Owned<IFile> daliConfigFile = createIFile("daliconf.xml");
if (daliConfigFile->exists())
{
Owned<IPropertyTree> daliConfig = createPTree(*daliConfigFile, ipt_caseInsensitive);
port = daliConfig->getPropInt("@port", DALI_SERVER_PORT);
server = ".";
}
else
usage();
}
}
else
{
initNullConfiguration();
server = argv[1];
port = DALI_SERVER_PORT;
}
Expand Down
2 changes: 2 additions & 0 deletions dali/sasha/sasha.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ int main(int argc, char* argv[])
EnableSEHtoExceptionMapping();
Thread::setDefaultStackSize(0x10000);
try {
initNullConfiguration();

startMPServer(0);
attachStandardFileLogMsgMonitor("sasha.log", NULL, MSGFIELD_STANDARD, MSGAUD_all, MSGCLS_all, TopDetail, LOGFORMAT_table, true);
queryStderrLogMsgHandler()->setMessageFields(MSGFIELD_prefix);
Expand Down
8 changes: 8 additions & 0 deletions system/jlib/jptree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9099,6 +9099,14 @@ void replaceComponentConfig(IPropertyTree *newComponentConfig, IPropertyTree *ne
executeConfigUpdaterCallbacks();
}

void initNullConfiguration()
{
if (componentConfiguration || globalConfiguration)
throw makeStringException(99, "Configuration has already been initialised");
componentConfiguration.setown(createPTree());
globalConfiguration.setown(createPTree());
}

class CYAMLBufferReader : public CInterfaceOf<IPTreeReader>
{
protected:
Expand Down
1 change: 1 addition & 0 deletions system/jlib/jptree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ jlib_decl IPropertyTree * loadArgsIntoConfiguration(IPropertyTree *config, const
jlib_decl IPropertyTree * loadConfiguration(IPropertyTree * defaultConfig, const char * * argv, const char * componentTag, const char * envPrefix, const char * legacyFilename, IPropertyTree * (mapper)(IPropertyTree *), const char *altNameAttribute=nullptr, bool monitor=true);
jlib_decl IPropertyTree * loadConfiguration(const char * defaultYaml, const char * * argv, const char * componentTag, const char * envPrefix, const char * legacyFilename, IPropertyTree * (mapper)(IPropertyTree *), const char *altNameAttribute=nullptr, bool monitor=true);
jlib_decl void replaceComponentConfig(IPropertyTree *newComponentConfig, IPropertyTree *newGlobalConfig);
jlib_decl void initNullConfiguration();
jlib_decl IPropertyTree * getCostsConfiguration();

//The following can only be called after loadConfiguration has been called. All components must call loadConfiguration().
Expand Down

0 comments on commit 4a983bf

Please sign in to comment.