Skip to content

237 configurable path to gravityini#251

Open
astrauc wants to merge 16 commits intomasterfrom
237-configurable-path-to-gravityini
Open

237 configurable path to gravityini#251
astrauc wants to merge 16 commits intomasterfrom
237-configurable-path-to-gravityini

Conversation

@astrauc
Copy link
Copy Markdown
Contributor

@astrauc astrauc commented Jan 14, 2026

Configurable path to Gravity.ini exists now as an environmental variable and an optional parameter to the GravityNode::init function. Init function now one function with 2 optional parameters instead of an overloaded function.

config_file.ini can be specified with command line argument now when running ConfigServer (argument is the directory to look in).

@astrauc astrauc linked an issue Jan 14, 2026 that may be closed by this pull request
@mbarger99
Copy link
Copy Markdown
Contributor

Thanks for looking at this @astrauc. Can you also update the ServiceDirectory and other components to take a filename arg like you did with the ConfigServer? For those, please stick with "Gravity.ini" as the default.

Is this ready for review otherwise?

@astrauc
Copy link
Copy Markdown
Contributor Author

astrauc commented Jan 20, 2026

Changes to have all components take in args for Gravity.ini. If the checks pass, it should be ready for review.

Comment thread src/api/cpp/GravityConfigParser.cpp Outdated

KeyValueConfigParser parser(config_filename, sections);
std::string path = config_dir;
if (path.rfind('/') != std::string::npos)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be missing something, but I think the logic is a little off here - the '/' isn't found if rfind returns string::npos. It should also avoid adding '/' to an empty path.

Suggested change
if (path.rfind('/') != std::string::npos)
if (path.size() > 0 && path.rfind('/') == std::string::npos)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, that delimiter should be updated to work on windows. If we specify c++17 or newer (which we should do anyway), we could use std::filesystem::path::preferred_separator.

@cbrundick
Copy link
Copy Markdown
Contributor

@astrauc - The command line argument should be the full path (including filename) for the configuration INI.

@astrauc
Copy link
Copy Markdown
Contributor Author

astrauc commented Jan 21, 2026

The arguments now take in full filepath, including filename, which should resolve both issues, since no separator needs to be added anymore.

//log an error indicating the componentID was missing
logger->error(
"Field 'GravityComponentID' missing from Gravity.ini, using GravityComponentID='GravityNode'");
configSpdLoggers();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be called after acquiring the initLock. We should also add a note on that method that it needs to be called within a lock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configurable path to Gravity.ini

4 participants