diff options
author | Roland Reichwein <mail@reichwein.it> | 2025-01-20 21:56:53 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2025-01-20 21:56:53 +0100 |
commit | 2c5684482c14764cec4fb32b2ec07dd3f77fd4bf (patch) | |
tree | 9ff9c5c04a20c30568f4ce1c466fe55818a0b45b /MainLoop.cpp | |
parent | 5fd637644c7529bfdc5291215f3f8ee1edd304c4 (diff) |
Diffstat (limited to 'MainLoop.cpp')
-rw-r--r-- | MainLoop.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
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; |