mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 11:29:23 +00:00
Print background jobs in status
This commit is contained in:
parent
7ab3c22114
commit
fcb9e25fb1
3 changed files with 25 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
23
src/util.cpp
23
src/util.cpp
|
@ -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
|
||||
|
|
|
@ -107,6 +107,7 @@ public:
|
|||
void start(const char* name);
|
||||
void stop(const char* name);
|
||||
void wait();
|
||||
void print_status();
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
|
|
Loading…
Reference in a new issue