5 #include "abstractfork.h" 9 #include <QFileSystemWatcher> 10 #include <QLoggingCategory> 13 Q_LOGGING_CATEGORY(C_SERVER_FORK,
"cutelyst.server.fork", QtWarningMsg)
15 AbstractFork::AbstractFork(
QObject *parent)
20 void AbstractFork::setTouchReload(
const QStringList &paths)
22 m_touchReloadPaths = paths;
25 void AbstractFork::installTouchReload()
27 if (!m_touchReloadPaths.isEmpty() && !m_touchReloadWatcher) {
32 &AbstractFork::fileChanged);
36 &AbstractFork::directoryChanged);
37 const QStringList ret = m_touchReloadWatcher->addPaths(m_touchReloadPaths);
39 std::cerr <<
"Failed setup file watcher\n";
40 qCCritical(C_SERVER_FORK) <<
"unwatched files" << ret;
44 m_restartTimer =
new QTimer(
this);
46 m_restartTimer->setInterval(std::chrono::seconds{1});
47 m_restartTimer->setSingleShot(
true);
51 void AbstractFork::removeTouchReload()
53 delete m_touchReloadWatcher;
54 m_touchReloadWatcher =
nullptr;
56 delete m_restartTimer;
59 void AbstractFork::fileChanged(
const QString &path)
61 std::cout <<
"File changed restarting... " << qPrintable(path) <<
'\n';
62 m_restartTimer->start();
65 void AbstractFork::directoryChanged(
const QString &path)
67 std::cout <<
"Directory changed restarting... " << qPrintable(path) <<
'\n';
68 m_restartTimer->start();
71 #include "moc_abstractfork.cpp" QFuture< ArgsType< Signal >> connect(Sender *sender, Signal signal)
void fileChanged(const QString &path)
void directoryChanged(const QString &path)