-
Notifications
You must be signed in to change notification settings - Fork 34
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
Watchdog #1870
Watchdog #1870
Conversation
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
Signed-off-by: Igor Egorov <igor@qdrvm.io>
Signed-off-by: Igor Egorov <igor@qdrvm.io>
Signed-off-by: Igor Egorov <igor@qdrvm.io>
Signed-off-by: Igor Egorov <igor@qdrvm.io>
Signed-off-by: Igor Egorov <igor@qdrvm.io>
core/utils/watchdog.hpp
Outdated
std::shared_ptr<Atomic> count_; | ||
|
||
void operator()() { | ||
++*count_; |
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.
++*count_; | |
count_->fetch_add(1); |
core/utils/watchdog.hpp
Outdated
if (lag > timeout) { | ||
std::stringstream s; | ||
s << it->first; | ||
fmt::print( |
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.
Let's use SL_CRITICAL. It flushes all collected buffers after add log message
core/utils/watchdog.hpp
Outdated
void run(std::shared_ptr<boost::asio::io_context> io) { | ||
auto ping = add(); | ||
while (not stopped_ and not io.unique()) { | ||
#if 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.
if constexpr (false)
would be better - selective compilation with checking both branches.
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.
No, if constexpr (false)
doesn't compile here (requires template).
std::chrono::seconds wait{1};
[&](auto &io) {
boost::system::error_code ec;
auto wait_us = std::chrono::duration_cast<std::chrono::microseconds>(wait);
if constexpr (requires { io->impl_.wait_one(wait_us.count(), ec); }) {
io->impl_.wait_one(wait_us.count(), ec);
ping();
io->poll_one();
} else {
io->run_one_for(wait);
}
}(io);
Signed-off-by: Igor Egorov <igor@qdrvm.io>
Signed-off-by: Igor Egorov <igor@qdrvm.io>
Signed-off-by: Igor Egorov <igor@qdrvm.io>
Referenced issues
Description of the Change
An implementation of in-process watchdog based on timing out boost asio loops.
Default timeout is set to be 15 min.
Benefits
Not an over-complicated implementation.
Possible Drawbacks
The watchdog would not track the whole process state.