2019-03-29 07:34:14 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* TestPlugin.cc
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "TestPlugin.h"
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
using namespace drogon;
|
|
|
|
|
|
|
|
void TestPlugin::initAndStart(const Json::Value &config)
|
|
|
|
{
|
|
|
|
/// Initialize and start the plugin
|
2019-05-18 12:39:57 +00:00
|
|
|
if (config.isNull())
|
2019-03-29 07:34:14 +00:00
|
|
|
LOG_DEBUG << "Configuration not defined";
|
|
|
|
_interval = config.get("heartbeat_interval", 1).asInt();
|
|
|
|
_workThread = std::thread([this]() {
|
2019-05-18 12:39:57 +00:00
|
|
|
while (!_stop)
|
2019-03-29 07:34:14 +00:00
|
|
|
{
|
|
|
|
LOG_DEBUG << "TestPlugin heartbeat!";
|
|
|
|
sleep(_interval);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-05-18 12:39:57 +00:00
|
|
|
void TestPlugin::shutdown()
|
2019-03-29 07:34:14 +00:00
|
|
|
{
|
|
|
|
/// Shutdown the plugin
|
|
|
|
_stop = true;
|
|
|
|
_workThread.join();
|
|
|
|
}
|