|
|
|
@ -32,6 +32,7 @@
|
|
|
|
|
#include <websocketpp/server.hpp>
|
|
|
|
|
|
|
|
|
|
#include <sys/eventfd.h>
|
|
|
|
|
#include <sys/inotify.h>
|
|
|
|
|
#include <sys/signal.h>
|
|
|
|
|
#include <sys/signalfd.h>
|
|
|
|
|
|
|
|
|
@ -401,6 +402,7 @@ Server::Server(LaminarInterface& li, kj::StringPtr rpcBindAddress,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
// handle SIGCHLD
|
|
|
|
|
{
|
|
|
|
|
sigset_t mask;
|
|
|
|
|
sigemptyset(&mask);
|
|
|
|
|
sigaddset(&mask, SIGCHLD);
|
|
|
|
@ -415,6 +417,17 @@ Server::Server(LaminarInterface& li, kj::StringPtr rpcBindAddress,
|
|
|
|
|
}).attach(std::move(event)).attach(std::move(buffer));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// handle watched paths
|
|
|
|
|
{
|
|
|
|
|
inotify_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
|
|
|
|
|
auto event = ioContext.lowLevelProvider->wrapInputFd(inotify_fd, kj::LowLevelAsyncIoProvider::TAKE_OWNERSHIP);
|
|
|
|
|
auto buffer = kj::heapArrayBuilder<char>(PROC_IO_BUFSIZE);
|
|
|
|
|
pathWatch = handleFdRead(event, buffer.asPtr().begin(), [this](const char*, size_t){
|
|
|
|
|
laminarInterface.notifyConfigChanged();
|
|
|
|
|
}).attach(std::move(event)).attach(std::move(buffer));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Server::~Server() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -455,6 +468,10 @@ void Server::addDescriptor(int fd, std::function<void(const char*,size_t)> cb) {
|
|
|
|
|
childTasks.add(handleFdRead(event, buffer.asPtr().begin(), cb).attach(std::move(event)).attach(std::move(buffer)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Server::addWatchPath(const char* dpath) {
|
|
|
|
|
inotify_add_watch(inotify_fd, dpath, IN_ONLYDIR | IN_CLOSE_WRITE | IN_CREATE | IN_DELETE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kj::Promise<void> Server::acceptHttpClient(kj::Own<kj::ConnectionReceiver>&& listener) {
|
|
|
|
|
kj::ConnectionReceiver& cr = *listener.get();
|
|
|
|
|
return cr.accept().then(kj::mvCapture(kj::mv(listener),
|
|
|
|
|