aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2002-03-19 22:55:17 +0000
committertradke <tradke@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2002-03-19 22:55:17 +0000
commit67b52a797193b27df3f2b2e8944f166b2c977556 (patch)
treef2e14d0c6819ed828ab1037ad250c1d4eda4c694
parent04e9f2aaf36d7c0e93e3c4f3985f4dfe9fbb1551 (diff)
Check for a shell variable HTTPD_PORT. If this is set take its value as the
port number to use for HTTPD and ignore the setting of 'httpd::port'. This closes PR CactusConnect/930. git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@159 1faa4e14-9dd3-4be0-9f0e-ffe519881164
-rw-r--r--src/Startup.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/Startup.c b/src/Startup.c
index 440a888..57e43a5 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -87,7 +87,9 @@ static int thread_started = 0;
static int http_actualport=5555; /* bad bad static var (should use GH) */
int HTTP_Startup(void)
{
+ int use_port;
httpState state;
+ char *environ_port;
DECLARE_CCTK_PARAMETERS
@@ -99,7 +101,29 @@ int HTTP_Startup(void)
}
#endif
- http_actualport = port;
+ /* get HTTPD port to use from the 'port' parameter or the shell environment */
+ use_port = port;
+ environ_port = getenv ("HTTPD_PORT");
+ if (environ_port)
+ {
+ use_port = atoi (environ_port);
+ if (use_port >= 1 && use_port <= 65535)
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, "Environment variable HTTPD_PORT is set to "
+ "%d and will override parameter setting from 'HTTPD::port'",
+ use_port);
+ }
+ else
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Environment variable HTTPD_PORT is set to '%s' which cannot "
+ "be parsed as a valid port number. Using parameter setting "
+ "'HTTPD::port = %d' instead.", environ_port, (int) port);
+ use_port = port;
+ }
+ }
+ http_actualport = use_port;
+
if(CCTK_MyProc(NULL) == 0)
{
/* Does the server provide any pages by default ? */
@@ -108,11 +132,11 @@ int HTTP_Startup(void)
HTTP_RegisterPages();
}
- http_actualport = HTTP_SetupServer(port, queue_length, hunt);
+ http_actualport = HTTP_SetupServer(use_port, queue_length, hunt);
}
/* Do we need to redirect to a master server ? */
- HTTP_SetupRedirect(port,queue_length,hunt);
+ HTTP_SetupRedirect(use_port,queue_length,hunt);
HTTP_UpdateState(NULL, &state);