From c0d9d61e3330d4f69a9547cc3d0e62970fb7427e Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 13 Jan 2023 17:40:09 +0100 Subject: Added webapp-runner --- plugins/fcgi/webapp-runner.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 plugins/fcgi/webapp-runner.cpp (limited to 'plugins/fcgi/webapp-runner.cpp') diff --git a/plugins/fcgi/webapp-runner.cpp b/plugins/fcgi/webapp-runner.cpp new file mode 100644 index 0000000..64268f3 --- /dev/null +++ b/plugins/fcgi/webapp-runner.cpp @@ -0,0 +1,54 @@ +#include "plugins/fcgi/fastcgiprocess.h" + +#include +#include + +namespace { + void usage() + { + std::cout << R"(Usage: + webapp-runner + + or: + + webapp-runner + +Description: + +webapp-runner starts the specified executable FastCGI application and connects +it to the specified unix domain socket or local host:port address. Addresses +can be specified in IPv4 or IPv6 format. + +Examples: + +webapp-runner ::1:6543 ./fcgi1 +webapp-runner fcgi-socket0 ./fcgi1 +)" << std::endl; + } +} // namespace + +int main(int argc, char* argv[]) +{ + try { + if (argc == 3) { + std::string address{argv[1]}; + std::string command{argv[2]}; + + if (auto pos{address.find_last_of(':')}; pos != std::string::npos) { + std::string host{address.substr(0, pos)}; + unsigned short port{static_cast(std::stoul(address.substr(pos + 1)))}; + run_fcgi_app(command, host, port); + } else { + run_fcgi_app(command, address); + } + } else { + usage(); + exit(0); + } + } catch (const std::exception& ex) { + std::cout << "webapp-runner caught error: " << ex.what() << std::endl; + } + + return 0; +} + -- cgit v1.2.3