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