-
Notifications
You must be signed in to change notification settings - Fork 129
Added osvr_server command-line options #529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…check on creating config file
…absense of config file
…logging-improvements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See questions/requests. Not sure, but I think this breaks server auto-start and default double-click behavior (with no command line arguments). Should look for a file with the default config file name in the CWD in that case and only use an empty config if that file does not exist either.
opt::options_description optionsVisible("Command Line Options"); | ||
opt::positional_options_description optionsPositional; | ||
|
||
optionsPositional.add("config", -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this make the config option the default option when only one argument is passed (like when you drag a config file over the server in windows explorer)? Just making sure we don't change the current behavior in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. So if you run osvr_server blah.json
then it will use blah.json
as the configuration file. The same thing happens if you drag and drop blah.json
onto the osvr_server.exe
program in Windows.
log->debug("Verbose logging enabled."); | ||
} | ||
|
||
configName = values["config"].as<std::string>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this line do if no command line arguments are passed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JeroMiya If no configuration file is specified, it will check to see if the file returned by osvr::server::getDefaultConfigFilename()
exists and is readable. If it is, then we'll use it. Otherwise, we'll start the server with an empty { }
configuration.
log->info() | ||
<< "Using default config file - pass a filename on the command " | ||
"line to use a different one."; | ||
server = osvr::server::configureServerFromString("{ }"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to also check for a file called osvr::server::getDefaultConfigFilename()
in the current working directory, so that we don't break server auto-start and double-click behavior (i.e. starting with no arguments should load the default config file name from the CWD). Only if the config is not specified, and the default-named config file is not found in the CWD, should we be using a blank config as is done here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no configuration file is specified on the command line, we assume the user specified the filename returned by osvr::server::getDefaultConfigFilename()
. If that file exists, we'll use it. If it doesn't, then we'll start the server with an empty { }
configuration.
If no configuration file is specified, we default to using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple clarifications are needed for my comments, but otherwise it looks good
configPath = boost::none; | ||
} | ||
|
||
if (configPath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming this check fails if you provide an empty string to boost::optional<fs::path> configPath(configName)
on line 111 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mars979 I think so, since I would expect fs::exists()
to return false on an empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, sounds good.
srvConfig.loadConfig(json); | ||
ret = srvConfig.constructServer(); | ||
} catch (std::exception &e) { | ||
log->error() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we log the std::exception error here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mars979 We are logging the exception here. (Or are you suggesting we shouldn't log it?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@godbyk , I meant to ask if log->error()
automatically logs the std::exception &e
or do you need to explicitly add log->error(e.what())
(or something similar)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mars979 Ah, gotcha. We're logging it a couple lines down. (clang-format's line-wrapping hinders the readability of the line.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it was just wrapped to next line. My bad.
This PR adds command-line options to the server for adjusting the log verbosity and also allows the server to run without specifying a configuration file (in which case it will assume an empty configuration
{ }
).Verbose logging sets the log level to
debug
and debug logging sets the log level totrace
.This subsumes PR #293 by @Outurnate.