summaryrefslogtreecommitdiffhomepage
path: root/MainLoop.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2025-01-20 21:56:53 +0100
committerRoland Reichwein <mail@reichwein.it>2025-01-20 21:56:53 +0100
commit2c5684482c14764cec4fb32b2ec07dd3f77fd4bf (patch)
tree9ff9c5c04a20c30568f4ce1c466fe55818a0b45b /MainLoop.cpp
parent5fd637644c7529bfdc5291215f3f8ee1edd304c4 (diff)
Add click-fcgi (WIP)HEADmaster
Diffstat (limited to 'MainLoop.cpp')
-rw-r--r--MainLoop.cpp24
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;