#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; }