Print background jobs in status

This commit is contained in:
SChernykh 2021-08-25 11:31:35 +02:00
parent 7ab3c22114
commit fcb9e25fb1
3 changed files with 25 additions and 0 deletions

View file

@ -100,6 +100,7 @@ static int do_status(p2pool *m_pool, const char * /* args */)
if (m_pool->p2p_server()) {
m_pool->p2p_server()->print_status();
}
bkg_jobs_tracker.print_status();
return 0;
}

View file

@ -183,6 +183,24 @@ struct BackgroundJobTracker::Impl
} while (1);
}
void print_status()
{
MutexLock lock(m_lock);
if (m_jobs.empty()) {
LOGINFO(0, "no background jobs running");
return;
}
char buf[log::Stream::BUF_SIZE + 1];
log::Stream s(buf);
for (const auto& job : m_jobs) {
s << '\n' << job.first << " (" << job.second << ')';
}
LOGINFO(0, "background jobs running:" << log::const_buf(buf, s.m_pos));
}
uv_mutex_t m_lock;
std::map<std::string, int32_t> m_jobs;
};
@ -211,6 +229,11 @@ void BackgroundJobTracker::wait()
m_impl->wait();
}
void BackgroundJobTracker::print_status()
{
m_impl->print_status();
}
BackgroundJobTracker bkg_jobs_tracker;
} // namespace p2pool

View file

@ -107,6 +107,7 @@ public:
void start(const char* name);
void stop(const char* name);
void wait();
void print_status();
private:
struct Impl;