From 2c5684482c14764cec4fb32b2ec07dd3f77fd4bf Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Mon, 20 Jan 2025 21:56:53 +0100 Subject: Add click-fcgi (WIP) --- MainLoop.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'MainLoop.cpp') diff --git a/MainLoop.cpp b/MainLoop.cpp index b6331a2..ba026f2 100644 --- a/MainLoop.cpp +++ b/MainLoop.cpp @@ -22,6 +22,8 @@ using namespace std::chrono_literals; using namespace std::string_literals; +namespace bp = boost::process; + MainLoop::MainLoop(int argc, char** argv): m_status{}, m_config{argc, argv}, @@ -34,6 +36,28 @@ MainLoop::MainLoop(int argc, char** argv): { m_status.add(LED{"/sys/class/leds/ACT", "/sys/class/leds/PWR"}); m_status.add(LED{"/sys/class/leds/thingm1:green:led1", "/sys/class/leds/thingm1:red:led1"}); + + start_fcgi(); +} + +MainLoop::~MainLoop() +{ + stop_fcgi(); +} + +void MainLoop::start_fcgi() +{ + m_child_fcgi = bp::child("spawn-fcgi -a 127.0.0.1 -p 9090 -n -- ./click-fcgi"); + if (!m_child_fcgi.valid() || !m_child_fcgi.running()) { + throw std::runtime_error("click-fcgi not started"); + } +} + +void MainLoop::stop_fcgi() +{ + if (m_child_fcgi.valid()) { + m_child_fcgi.terminate(); + } } bool run_flag = true; -- cgit v1.2.3