You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2011/06/05 07:35:43 UTC
svn commit: r1131807 - in /incubator/mesos/trunk/src: master_main.cpp
master_webui.cpp master_webui.hpp webui/master/webui.py
Author: benh
Date: Sun Jun 5 05:35:42 2011
New Revision: 1131807
URL: http://svn.apache.org/viewvc?rev=1131807&view=rev
Log:
Adds --webui-port flag to Mesos master. Closes #51.
Modified:
incubator/mesos/trunk/src/master_main.cpp
incubator/mesos/trunk/src/master_webui.cpp
incubator/mesos/trunk/src/master_webui.hpp
incubator/mesos/trunk/src/webui/master/webui.py
Modified: incubator/mesos/trunk/src/master_main.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master_main.cpp?rev=1131807&r1=1131806&r2=1131807&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master_main.cpp (original)
+++ incubator/mesos/trunk/src/master_main.cpp Sun Jun 5 05:35:42 2011
@@ -15,6 +15,7 @@ void usage(const char* programName)
cerr << "Usage: " << programName
<< " [--url URL]"
<< " [--port PORT]"
+ << " [--webui-port PORT]"
<< " [--allocator ALLOCATOR]"
<< " [--quiet]" << endl
<< endl
@@ -36,6 +37,7 @@ int main (int argc, char **argv)
{"url", required_argument, 0, 'u'},
{"allocator", required_argument, 0, 'a'},
{"port", required_argument, 0, 'p'},
+ {"webui-port", required_argument, 0, 'w'},
{"quiet", no_argument, 0, 'q'},
};
@@ -45,7 +47,8 @@ int main (int argc, char **argv)
int opt;
int index;
- while ((opt = getopt_long(argc, argv, "u:a:p:q", options, &index)) != -1) {
+ string webuiport = "";
+ while ((opt = getopt_long(argc, argv, "u:a:p:w:q", options, &index)) != -1) {
switch (opt) {
case 'u':
url = optarg;
@@ -56,6 +59,9 @@ int main (int argc, char **argv)
case 'p':
setenv("LIBPROCESS_PORT", optarg, 1);
break;
+ case 'w':
+ webuiport = optarg;
+ break;
case 'q':
quiet = true;
break;
@@ -87,7 +93,7 @@ int main (int argc, char **argv)
#ifdef NEXUS_WEBUI
if (chdir(dirname(argv[0])) != 0)
fatalerror("could not change into %s for running webui", dirname(argv[0]));
- startMasterWebUI(pid);
+ startMasterWebUI(pid, webuiport);
#endif
Process::wait(pid);
Modified: incubator/mesos/trunk/src/master_webui.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master_webui.cpp?rev=1131807&r1=1131806&r2=1131807&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master_webui.cpp (original)
+++ incubator/mesos/trunk/src/master_webui.cpp Sun Jun 5 05:35:42 2011
@@ -19,10 +19,17 @@ PID master;
namespace nexus { namespace internal { namespace master {
-void *runMasterWebUI(void *)
+void *runMasterWebUI(void * webuiport)
{
+ string portstring = *(string*)webuiport;
+ char shortstr[50];
+ portstring.copy(shortstr,20);
LOG(INFO) << "Web UI thread started";
Py_Initialize();
+ char** nargv = (char**)malloc(sizeof(char*)*2);
+ nargv[0] = "webui/master/webui.py";
+ nargv[1] = shortstr;
+ PySys_SetArgv(2,nargv);
PyRun_SimpleString("import sys\n"
"sys.path.append('webui/master/swig')\n"
"sys.path.append('webui/common')\n"
@@ -36,12 +43,12 @@ void *runMasterWebUI(void *)
}
-void startMasterWebUI(PID master)
+void startMasterWebUI(PID master, string webuiport)
{
LOG(INFO) << "Starting master web UI";
::master = master;
pthread_t thread;
- pthread_create(&thread, 0, runMasterWebUI, 0);
+ pthread_create(&thread, 0, runMasterWebUI, &webuiport);
}
Modified: incubator/mesos/trunk/src/master_webui.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master_webui.hpp?rev=1131807&r1=1131806&r2=1131807&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master_webui.hpp (original)
+++ incubator/mesos/trunk/src/master_webui.hpp Sun Jun 5 05:35:42 2011
@@ -10,7 +10,7 @@
namespace nexus { namespace internal { namespace master {
-void startMasterWebUI(PID master);
+void startMasterWebUI(PID master, string webuiport);
}}} /* namespace */
Modified: incubator/mesos/trunk/src/webui/master/webui.py
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/webui/master/webui.py?rev=1131807&r1=1131806&r2=1131807&view=diff
==============================================================================
--- incubator/mesos/trunk/src/webui/master/webui.py (original)
+++ incubator/mesos/trunk/src/webui/master/webui.py Sun Jun 5 05:35:42 2011
@@ -1,3 +1,4 @@
+import sys
import bottle
import commands
import datetime
@@ -37,4 +38,8 @@ def log_tail(level, lines):
bottle.TEMPLATE_PATH.append('./webui/master/%s.tpl')
-bottle.run(host = '0.0.0.0', port = 8080)
+if sys.argv[1]:
+ init_port = sys.argv[1]
+else:
+ init_port = 8080
+bottle.run(host = '0.0.0.0', port = init_port)