summaryrefslogtreecommitdiffhomepage
path: root/plugins/fcgi/webapp-runner.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-01-13 17:40:09 +0100
committerRoland Reichwein <mail@reichwein.it>2023-01-13 17:40:09 +0100
commitc0d9d61e3330d4f69a9547cc3d0e62970fb7427e (patch)
treeffc906ba3ddbe97dbf1042b14063caa7debe141d /plugins/fcgi/webapp-runner.cpp
parentd14582a1d92e036780166a0b5ec0494d7353cc75 (diff)
Added webapp-runner
Diffstat (limited to 'plugins/fcgi/webapp-runner.cpp')
-rw-r--r--plugins/fcgi/webapp-runner.cpp54
1 files changed, 54 insertions, 0 deletions
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 <iostream>
+#include <string>
+
+namespace {
+ void usage()
+ {
+ std::cout << R"(Usage:
+ webapp-runner <host:port> <executable-command>
+
+ or:
+
+ webapp-runner <unix-domain-socket> <executable-command>
+
+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<unsigned short>(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;
+}
+