trafficcontrol-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dang...@apache.org
Subject [1/2] incubator-trafficcontrol git commit: moves server.js to root of traffic portal directory to support docker only setup
Date Mon, 03 Jul 2017 15:33:08 GMT
Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/master 0bfb2cb73 -> cddf6db00


moves server.js to root of traffic portal directory to support docker only setup


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/7e6c2d60
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/7e6c2d60
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/7e6c2d60

Branch: refs/heads/master
Commit: 7e6c2d6022cc1cc6a5d58fa0053ccf242b3e998d
Parents: 0bfb2cb
Author: Jeremy Mitchell <mitchell852@gmail.com>
Authored: Mon Jul 3 09:17:22 2017 -0600
Committer: Dan Kirkwood <dangogh@gmail.com>
Committed: Mon Jul 3 09:32:34 2017 -0600

----------------------------------------------------------------------
 traffic_portal/build/etc/init.d/traffic_portal |   2 +-
 traffic_portal/build/traffic_portal.spec       |   2 +-
 traffic_portal/conf/config.js                  |   2 +-
 traffic_portal/docker/Dockerfile               |   5 +-
 traffic_portal/server.js                       | 160 ++++++++++++++++++++
 traffic_portal/server/server.js                | 160 --------------------
 6 files changed, 165 insertions(+), 166 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/7e6c2d60/traffic_portal/build/etc/init.d/traffic_portal
----------------------------------------------------------------------
diff --git a/traffic_portal/build/etc/init.d/traffic_portal b/traffic_portal/build/etc/init.d/traffic_portal
index 9b9c384..739c9b3 100755
--- a/traffic_portal/build/etc/init.d/traffic_portal
+++ b/traffic_portal/build/etc/init.d/traffic_portal
@@ -59,7 +59,7 @@ NAME="Traffic Portal Application"
 NODE_BIN_DIR="/usr/bin"
 NODE_PATH="/opt/traffic_portal/node_modules"
 FOREVER_BIN_DIR="/opt/traffic_portal/node_modules/forever/bin"
-APPLICATION_PATH="/opt/traffic_portal/server/server.js"
+APPLICATION_PATH="/opt/traffic_portal/server.js"
 PIDFILE="/var/run/traffic_portal.pid"
 LOGFILE="/var/log/traffic_portal/traffic_portal.log"
 MIN_UPTIME="5000"

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/7e6c2d60/traffic_portal/build/traffic_portal.spec
----------------------------------------------------------------------
diff --git a/traffic_portal/build/traffic_portal.spec b/traffic_portal/build/traffic_portal.spec
index 6881030..db9a689 100644
--- a/traffic_portal/build/traffic_portal.spec
+++ b/traffic_portal/build/traffic_portal.spec
@@ -60,7 +60,7 @@ tar -xzvf $RPM_SOURCE_DIR/traffic_portal-%{version}.tgz
     JSON_VERSION="{\n$VERSION,\n$BUILD_NUMBER,\n$BUILD_DATE\n}"
     echo -e $JSON_VERSION > ${RPM_BUILD_ROOT}%{traffic_portal_home}/public/traffic_portal_release.json
 
-    %__cp ${RPM_BUILD_DIR}/traffic_portal-%{version}/server/server.js ${RPM_BUILD_ROOT}%{traffic_portal_home}/server/.
+    %__cp ${RPM_BUILD_DIR}/traffic_portal-%{version}/server.js ${RPM_BUILD_ROOT}%{traffic_portal_home}/.
     %__cp -r ${RPM_BUILD_DIR}/traffic_portal-%{version}/conf ${RPM_BUILD_ROOT}/etc/traffic_portal/.
     %__cp ${RPM_BUILD_DIR}/traffic_portal-%{version}/build/etc/init.d/traffic_portal ${RPM_BUILD_ROOT}/etc/init.d/.
     %__cp ${RPM_BUILD_DIR}/traffic_portal-%{version}/build/etc/logrotate.d/traffic_portal
${RPM_BUILD_ROOT}/etc/logrotate.d/.

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/7e6c2d60/traffic_portal/conf/config.js
----------------------------------------------------------------------
diff --git a/traffic_portal/conf/config.js b/traffic_portal/conf/config.js
index b4611a0..63c0e56 100644
--- a/traffic_portal/conf/config.js
+++ b/traffic_portal/conf/config.js
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-// this is the config that is consumed by server/server.js
+// this is the config that is consumed by /server.js on application startup
 module.exports = {
     timeout: '120s',
     useSSL: false, // set to true if you plan to use https (self-signed or trusted certs).

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/7e6c2d60/traffic_portal/docker/Dockerfile
----------------------------------------------------------------------
diff --git a/traffic_portal/docker/Dockerfile b/traffic_portal/docker/Dockerfile
index 6e699e9..7c1ebd1 100644
--- a/traffic_portal/docker/Dockerfile
+++ b/traffic_portal/docker/Dockerfile
@@ -20,6 +20,5 @@ RUN apt-get update -y && apt-get install libffi-dev ruby-dev rubygems
vim -y
 RUN gem update --system && gem install --no-rdoc --no-ri compass && gem install
--no-rdoc --no-ri sass -v 3.4.22
 RUN npm install -g bower grunt-cli
 RUN echo '{ "allow_root": true }' > /root/.bowerrc
-
-ADD infrastructure/docker/build/clean_build.sh /
-CMD /clean_build.sh traffic_portal
+RUN cd /usr/src/app && /usr/local/bin/bower install
+RUN cd /usr/src/app && /usr/local/bin/grunt dist

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/7e6c2d60/traffic_portal/server.js
----------------------------------------------------------------------
diff --git a/traffic_portal/server.js b/traffic_portal/server.js
new file mode 100644
index 0000000..d87851e
--- /dev/null
+++ b/traffic_portal/server.js
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+var constants = require('constants'),
+    express = require('express'),
+    http = require('http'),
+    https = require('https'),
+    path = require('path'),
+    fs = require('fs'),
+    morgan = require('morgan'),
+    modRewrite = require('connect-modrewrite'),
+    timeout = require('connect-timeout');
+
+var config;
+
+try {
+    config = require('/etc/traffic_portal/conf/config');
+}
+catch(e) {
+    config = require('./conf/config');
+}
+
+var logStream = fs.createWriteStream(config.log.stream, { flags: 'a' }),
+    useSSL = config.useSSL;
+
+// Disable for self-signed certs in dev/test
+process.env.NODE_TLS_REJECT_UNAUTHORIZED = config.reject_unauthorized;
+
+var app = express();
+
+app.use(function(req, res, next) {
+    var err = null;
+    try {
+        decodeURIComponent(req.path)
+    }
+    catch(e) {
+        err = e;
+    }
+    if (err){
+        console.log(err, req.url);
+    }
+    next();
+});
+
+// Add a handler to inspect the req.secure flag (see
+// http://expressjs.com/api#req.secure). This allows us
+// to know whether the request was via http or https.
+app.all ("/*", function (req, res, next) {
+    if (useSSL && !req.secure) {
+        // request was via http, so redirect to https
+        return res.redirect(['https://', req.get('Host'), ':', config.sslPort, req.url].join(''));
+    } else {
+        // request was via https or useSSL=false, so do no special handling
+        next();
+    }
+});
+
+app.use(modRewrite([
+    '^/api/(.*?)\\?(.*)$ ' + config.api.base_url + '$1?$2 [P]',
+    '^/api/(.*)$ ' + config.api.base_url + '$1 [P]'
+]));
+
+app.use(express.static(config.files.static));
+app.use(morgan('combined', {
+    stream: logStream,
+    skip: function (req, res) { return res.statusCode < 400 }
+}));
+app.use(timeout(config.timeout));
+
+if (app.get('env') === 'dev') {
+    app.use(require('connect-livereload')({
+        port: 35728,
+        excludeList: ['.woff', '.flv']
+    }));
+} else {
+    app.set('env', 'production');
+}
+
+// special handling required for dbdump. haven't got this to work yet
+// app.get('/dbdump', function (req, res) {
+//     var port = (useSSL) ? config.sslPort : config.port,
+//         options = {
+//             method: 'GET',
+//             host: 'localhost',
+//             port: port,
+//             path: '/api/1.2/dbdump',
+//             headers: {
+//                 cookie: req.headers['cookie']
+//             }
+//         };
+//
+//     var request = http.request(options, function(response) {
+//         var data = [];
+//         console.log(response.statusCode);
+//         response.on('data', function(chunk) {
+//             data.push(chunk);
+//         });
+//         response.on('end', function() {
+//             data = Buffer.concat(data);
+//             res.writeHead(200, {
+//                 'Content-Type': 'application/download',
+//                 'Content-Disposition': 'attachment; filename=foo.dump.gz',
+//                 'Content-Length': data.length
+//             });
+//             res.end(data);
+//         });
+//     });
+//
+//     request.end();
+// });
+
+// Enable reverse proxy support in Express. This causes the
+// the "X-Forwarded-Proto" header field to be trusted so its
+// value can be used to determine the protocol. See
+// http://expressjs.com/api#app-settings for more details.
+app.enable('trust proxy');
+
+// Startup HTTP Server
+var httpServer = http.createServer(app);
+httpServer.listen(config.port);
+
+if (useSSL) {
+    //
+    // Supply `SSL_OP_NO_SSLv3` constant as secureOption to disable SSLv3
+    // from the list of supported protocols that SSLv23_method supports.
+    //
+    var sslOptions = {};
+    sslOptions['secureOptions'] = constants.SSL_OP_NO_SSLv3;
+
+    sslOptions['key'] = fs.readFileSync(config.ssl.key);
+    sslOptions['cert'] = fs.readFileSync(config.ssl.cert);
+    sslOptions['ca'] = config.ssl.ca.map(function(cert){
+        return fs.readFileSync(cert);
+    });
+
+    // Startup HTTPS Server
+    var httpsServer = https.createServer(sslOptions, app);
+    httpsServer.listen(config.sslPort);
+
+    sslOptions.agent = new https.Agent(sslOptions);
+}
+
+console.log("Traffic Portal Port         : %s", config.port);
+console.log("Traffic Portal SSL Port     : %s", config.sslPort);

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/7e6c2d60/traffic_portal/server/server.js
----------------------------------------------------------------------
diff --git a/traffic_portal/server/server.js b/traffic_portal/server/server.js
deleted file mode 100644
index d87851e..0000000
--- a/traffic_portal/server/server.js
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-
-var constants = require('constants'),
-    express = require('express'),
-    http = require('http'),
-    https = require('https'),
-    path = require('path'),
-    fs = require('fs'),
-    morgan = require('morgan'),
-    modRewrite = require('connect-modrewrite'),
-    timeout = require('connect-timeout');
-
-var config;
-
-try {
-    config = require('/etc/traffic_portal/conf/config');
-}
-catch(e) {
-    config = require('./conf/config');
-}
-
-var logStream = fs.createWriteStream(config.log.stream, { flags: 'a' }),
-    useSSL = config.useSSL;
-
-// Disable for self-signed certs in dev/test
-process.env.NODE_TLS_REJECT_UNAUTHORIZED = config.reject_unauthorized;
-
-var app = express();
-
-app.use(function(req, res, next) {
-    var err = null;
-    try {
-        decodeURIComponent(req.path)
-    }
-    catch(e) {
-        err = e;
-    }
-    if (err){
-        console.log(err, req.url);
-    }
-    next();
-});
-
-// Add a handler to inspect the req.secure flag (see
-// http://expressjs.com/api#req.secure). This allows us
-// to know whether the request was via http or https.
-app.all ("/*", function (req, res, next) {
-    if (useSSL && !req.secure) {
-        // request was via http, so redirect to https
-        return res.redirect(['https://', req.get('Host'), ':', config.sslPort, req.url].join(''));
-    } else {
-        // request was via https or useSSL=false, so do no special handling
-        next();
-    }
-});
-
-app.use(modRewrite([
-    '^/api/(.*?)\\?(.*)$ ' + config.api.base_url + '$1?$2 [P]',
-    '^/api/(.*)$ ' + config.api.base_url + '$1 [P]'
-]));
-
-app.use(express.static(config.files.static));
-app.use(morgan('combined', {
-    stream: logStream,
-    skip: function (req, res) { return res.statusCode < 400 }
-}));
-app.use(timeout(config.timeout));
-
-if (app.get('env') === 'dev') {
-    app.use(require('connect-livereload')({
-        port: 35728,
-        excludeList: ['.woff', '.flv']
-    }));
-} else {
-    app.set('env', 'production');
-}
-
-// special handling required for dbdump. haven't got this to work yet
-// app.get('/dbdump', function (req, res) {
-//     var port = (useSSL) ? config.sslPort : config.port,
-//         options = {
-//             method: 'GET',
-//             host: 'localhost',
-//             port: port,
-//             path: '/api/1.2/dbdump',
-//             headers: {
-//                 cookie: req.headers['cookie']
-//             }
-//         };
-//
-//     var request = http.request(options, function(response) {
-//         var data = [];
-//         console.log(response.statusCode);
-//         response.on('data', function(chunk) {
-//             data.push(chunk);
-//         });
-//         response.on('end', function() {
-//             data = Buffer.concat(data);
-//             res.writeHead(200, {
-//                 'Content-Type': 'application/download',
-//                 'Content-Disposition': 'attachment; filename=foo.dump.gz',
-//                 'Content-Length': data.length
-//             });
-//             res.end(data);
-//         });
-//     });
-//
-//     request.end();
-// });
-
-// Enable reverse proxy support in Express. This causes the
-// the "X-Forwarded-Proto" header field to be trusted so its
-// value can be used to determine the protocol. See
-// http://expressjs.com/api#app-settings for more details.
-app.enable('trust proxy');
-
-// Startup HTTP Server
-var httpServer = http.createServer(app);
-httpServer.listen(config.port);
-
-if (useSSL) {
-    //
-    // Supply `SSL_OP_NO_SSLv3` constant as secureOption to disable SSLv3
-    // from the list of supported protocols that SSLv23_method supports.
-    //
-    var sslOptions = {};
-    sslOptions['secureOptions'] = constants.SSL_OP_NO_SSLv3;
-
-    sslOptions['key'] = fs.readFileSync(config.ssl.key);
-    sslOptions['cert'] = fs.readFileSync(config.ssl.cert);
-    sslOptions['ca'] = config.ssl.ca.map(function(cert){
-        return fs.readFileSync(cert);
-    });
-
-    // Startup HTTPS Server
-    var httpsServer = https.createServer(sslOptions, app);
-    httpsServer.listen(config.sslPort);
-
-    sslOptions.agent = new https.Agent(sslOptions);
-}
-
-console.log("Traffic Portal Port         : %s", config.port);
-console.log("Traffic Portal SSL Port     : %s", config.sslPort);


Mime
View raw message