[mapguide-commits] r10091 - branches/4.0/MgDev/Web/src/DevHttpServer
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Jul 30 07:55:29 PDT 2024
Author: jng
Date: 2024-07-30 07:55:28 -0700 (Tue, 30 Jul 2024)
New Revision: 10091
Modified:
branches/4.0/MgDev/Web/src/DevHttpServer/main.cpp
Log:
Allow customizable hostname/IP for MgDevHttpServer to bind to via a new (and optional) --bind-to/-b parameter
Fixes #2881
Modified: branches/4.0/MgDev/Web/src/DevHttpServer/main.cpp
===================================================================
--- branches/4.0/MgDev/Web/src/DevHttpServer/main.cpp 2024-07-30 14:43:41 UTC (rev 10090)
+++ branches/4.0/MgDev/Web/src/DevHttpServer/main.cpp 2024-07-30 14:55:28 UTC (rev 10091)
@@ -65,6 +65,7 @@
{
if (!flag)
{
+ printf("Shutdown server\n");
g_server->stop();
flag = 1;
}
@@ -514,6 +515,7 @@
#endif
#endif
+ std::string bindTo;
std::string wwwroot;
STRING wcPath = L"webconfig.ini";
try
@@ -525,11 +527,13 @@
TCLAP::ValueArg<int> argPort("p", "port", "The port this server will listen on", false, 8000, "integer");
TCLAP::ValueArg<std::string> argWebConfigPath("w", "webconfig-path", "The path to webconfig.ini", false, "webconfig.ini", "path");
TCLAP::ValueArg<std::string> argWebRootPath("r", "wwwroot", "The path to the www root", false, "./wwwroot", "path");
+ TCLAP::ValueArg<std::string> argBindTo("b", "bind-to", "The hostname/IP to bind to", false, "localhost", "hostname/ip");
cmd.add(argMentorPath);
cmd.add(argPort);
cmd.add(argWebConfigPath);
cmd.add(argWebRootPath);
+ cmd.add(argBindTo);
cmd.parse(argc, argv);
@@ -557,6 +561,11 @@
{
wcPath = MgUtil::MultiByteToWideChar(argWebConfigPath.getValue());
}
+
+ if (argBindTo.isSet())
+ {
+ bindTo = argBindTo.getValue();
+ }
}
catch (TCLAP::ArgException& e)
{
@@ -599,8 +608,7 @@
g_server->Post("/mapguide/mapagent/mapagent.fcgi", MapAgentHandlerWithoutContentReader);
g_server->Get("/mapguide/mapagent/mapagent.fcgi", MapAgentHandlerWithoutContentReader);
- printf("Listening on port %d\n", port);
-
+ printf("Listening on port (%d) on (%s)\n", port, bindTo.c_str());
#ifdef _WIN32
if (!SetConsoleCtrlHandler(ConsoleControlHandler, TRUE))
@@ -610,8 +618,7 @@
#else
signal(SIGINT, LinuxControlHandler);
#endif
-
- g_server->listen("localhost", port);
+ g_server->listen(bindTo.c_str(), port);
}
{
More information about the mapguide-commits
mailing list