TEZ-2091. Add support for hosting TEZ_UI with nodejs. (Chang Li via hitesh)
Project: http://git-wip-us.apache.org/repos/asf/tez/repo Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/4a19a430 Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/4a19a430 Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/4a19a430 Branch: refs/heads/TEZ-2003 Commit: 4a19a430ef7e8e57e7f3fcd3d559efc9a3103601 Parents: 059b91b Author: Hitesh Shah <[email protected]> Authored: Fri Mar 6 13:43:29 2015 -0800 Committer: Hitesh Shah <[email protected]> Committed: Fri Mar 6 13:43:29 2015 -0800 ---------------------------------------------------------------------- CHANGES.txt | 1 + tez-ui/README.TXT | 16 ++++++++++++++ tez-ui/pom.xml | 2 ++ tez-ui/tools/server/nodejs_conf.json | 4 ++++ tez-ui/tools/server/nodejs_webserver.js | 32 ++++++++++++++++++++++++++++ tez-ui/tools/server/package.json | 8 +++++++ 6 files changed, 63 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tez/blob/4a19a430/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index da6900b..9bf6a08 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -80,6 +80,7 @@ Release 0.6.1: Unreleased INCOMPATIBLE CHANGES ALL CHANGES: + TEZ-2091. Add support for hosting TEZ_UI with nodejs. TEZ-2165. Tez UI: DAG shows running status if killed by RM in some cases. TEZ-2158. TEZ UI: Display dag/vertex names, and task/attempt index in breadcrumb. TEZ-2160. Tez UI: App tracking URL should support navigation back. http://git-wip-us.apache.org/repos/asf/tez/blob/4a19a430/tez-ui/README.TXT ---------------------------------------------------------------------- diff --git a/tez-ui/README.TXT b/tez-ui/README.TXT index d19f951..aa4564c 100644 --- a/tez-ui/README.TXT +++ b/tez-ui/README.TXT @@ -59,6 +59,22 @@ Manually: 3. Restart tomcat and the war will get deployed. The content of the war would be available in $TOMCAT_HOME/webapps/tez-ui-x.x.x-SNAPSHOT. +Using the Nodejs webserver +--------------------------- +This provides an alternative way to host tez_ui. This should be used by +people who would like to host tez_ui by nodejs. + 1. Install nodejs by package manager. Instructions for this are available at + "https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager" + 2. Install server dependencies by running 'npm install' within 'tez-ui/tools/server' + 3. Untar the tez-ui*.war file and copy the resulting directory to the + directory designated to be the document root of the web server. + 4. Specify the document root directory and the port on which you want to run the + webserver in nodejs_conf.json. Currently, the conf file should be present in the + same directory as the nodejs_webserver). + The default values for the document root directory and the port are './public' + and 8080 respectively. + 5. Start the nodejs_webserver.js by 'node nodejs_webserver.js' + Dev setup instructions ---------------------- Install the development dependencies nodejs, npm, grunt and bower. http://git-wip-us.apache.org/repos/asf/tez/blob/4a19a430/tez-ui/pom.xml ---------------------------------------------------------------------- diff --git a/tez-ui/pom.xml b/tez-ui/pom.xml index db9673f..ca4d7ab 100644 --- a/tez-ui/pom.xml +++ b/tez-ui/pom.xml @@ -51,6 +51,8 @@ <exclude>src/main/webapp/.jshintrc</exclude> <exclude>src/main/webapp/bower.json</exclude> <exclude>src/main/webapp/package.json</exclude> + <exclude>tools/server/nodejs_conf.json</exclude> + <exclude>tools/server/package.json</exclude> </excludes> </configuration> </plugin> http://git-wip-us.apache.org/repos/asf/tez/blob/4a19a430/tez-ui/tools/server/nodejs_conf.json ---------------------------------------------------------------------- diff --git a/tez-ui/tools/server/nodejs_conf.json b/tez-ui/tools/server/nodejs_conf.json new file mode 100644 index 0000000..a84b569 --- /dev/null +++ b/tez-ui/tools/server/nodejs_conf.json @@ -0,0 +1,4 @@ +{ + "UI_Dir" : "./public", + "port" : 8080 +} http://git-wip-us.apache.org/repos/asf/tez/blob/4a19a430/tez-ui/tools/server/nodejs_webserver.js ---------------------------------------------------------------------- diff --git a/tez-ui/tools/server/nodejs_webserver.js b/tez-ui/tools/server/nodejs_webserver.js new file mode 100644 index 0000000..8cd1975 --- /dev/null +++ b/tez-ui/tools/server/nodejs_webserver.js @@ -0,0 +1,32 @@ +/**** + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. See accompanying LICENSE file. +****/ + +var express = require('express') +var config = require('jsonconfig') +var app = express() +var path, port; +try { + config.load(['./nodejs_conf.json']) + path = config.UI_Dir || './public'; + port = config.port || 8080; +} catch(err) { + process.stdout.write("err: " + err); + path = './public'; + port = 8080; +} +app.use('/',express.static(path)) +app.listen(port); +process.stdout.write("TEZ-UI server started on port " + port + + "\n" + "Use CTRL+C to shutdown"); + http://git-wip-us.apache.org/repos/asf/tez/blob/4a19a430/tez-ui/tools/server/package.json ---------------------------------------------------------------------- diff --git a/tez-ui/tools/server/package.json b/tez-ui/tools/server/package.json new file mode 100644 index 0000000..91cf0fb --- /dev/null +++ b/tez-ui/tools/server/package.json @@ -0,0 +1,8 @@ +{ + "name": "express_server", + "version": "0.0.1", + "dependencies": { + "express": "4.12.1", + "jsonconfig": "0.3.0" + } +}
