summaryrefslogtreecommitdiffhomepage
path: root/plugins/fcgi/webapp-runner.cpp
diff options
context:
space:
mode:
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;
+}
+