-
Notifications
You must be signed in to change notification settings - Fork 232
Registry read and service errors handling #3766
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
…notoolkit/model_server into CVS-175101_service_errors
src/server.cpp
Outdated
| } catch (const std::exception& e) { | ||
| SPDLOG_ERROR("Exception; {}", e.what()); | ||
| result = OVMS_EX_FAILURE; | ||
| shutdown_request = 3; |
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.
Separate variable - for now it serves as comunnication from user to ovms to request stop. It would be better to have sth else to signal the other way arround -> that ovms stopped and ovms wrapper (service) needs to know. Ensure its reset when ovms is starting
src/main_windows.cpp
Outdated
|
|
||
| using ovms::Server; | ||
|
|
||
| OvmsWindowsServiceManager manager; |
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.
static inside function or singleton?
| int Server::getShutdownStatus() { | ||
| std::unique_lock lock{Server::shutdownMtx, std::defer_lock}; | ||
| auto locked = lock.try_lock(); | ||
| // Wait in windows thread until we can get the lock and check if ovms exited |
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 we could not get mtx we return 0, otherwise shutdown_request which could also be 0?
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.
0 for ShutdownStatus and ExitStatus means that the ovms thread - work - is still running. We can call the methods next time to check if anything changed, and if we got the mutex this time and we can read the specific variable - check if it is not 0.
| return statusToExitCode(ret); | ||
| } | ||
| while (!shutdown_request && | ||
| while (!getShutdownStatus() && |
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.
| while (!getShutdownStatus() && | |
| while (!getRequestedShutdown() && |
| int Server::start(int argc, char** argv) { | ||
| auto paramsOrExit = parseArgs(argc, argv); |
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.
Ideally this could be decoupled with Server:
we would have in main:
CLIParser parser;
parser.parse(argc,argv)
Then
server.start(serverSettings, modelsSettings)
| bool isReady() const; | ||
| bool isLive(const std::string& moduleName) const; | ||
|
|
||
| int getShutdownStatus(); |
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.
Private:
| int getShutdownStatus(); | ||
| void setShutdownRequest(int i); | ||
| int getExitStatus(); | ||
| void setExitStatus(int i); |
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.
Private:
atobiszei
left a comment
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.
To lower release delay risk change is accepted as is with comments to be addressed after release.
🛠 Summary
JIRA CVS-175101
🧪 Checklist
``