Switch to use express.js and update packging info

This commit is contained in:
sspeiche 2015-06-04 10:16:04 -04:00
parent cd4bd7201b
commit 202fdc3ea8
4 changed files with 14 additions and 54 deletions

View file

@ -1,27 +0,0 @@
# For documentation see https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml
# loggingEnabled: false
# debuggingEnabled: false
# devErrorsEnabled: false
node_env: production
# nodeProcessCountPerApplication: 1
# maxConcurrentRequestsPerProcess: 1024
# maxNamedPipeConnectionRetry: 24
# namedPipeConnectionRetryDelay: 250
# maxNamedPipeConnectionPoolSize: 512
# maxNamedPipePooledConnectionAge: 30000
# asyncCompletionThreadCount: 0
# initialRequestBufferSize: 4096
# maxRequestBufferSize: 65536
watchedFiles: iisnode.yml;node_modules\*;*.js
# uncFileChangesPollingInterval: 5000
# gracefulShutdownTimeout: 60000
# logDirectoryNameSuffix: logs
# debuggerPortRange: 5058-6058
# debuggerPathSegment: debug
# maxLogFileSizeInKB: 128
# appendToExistingLog: false
# logFileFlushInterval: 5000
# flushResponse: false
# enableXFF: false
# promoteServerVars:

View file

@ -1,7 +1,7 @@
{ {
"name": "node-echo", "name": "nodejs-ex",
"version": "0.0.1", "version": "0.0.1",
"description": "node-echo", "description": "Node.js sample app for OpenShift 3",
"main": "server.js", "main": "server.js",
"dependencies": { "dependencies": {
}, },
@ -18,15 +18,15 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "http://github.com/bettiolo/node-echo.git" "url": "http://github.com/openshift/nodejs-ex.git"
}, },
"keywords": [ "keywords": [
"Echo" "Echo"
], ],
"author": "Marco Bettiolo <marco@bettiolo.it>", "author": "Steve Speicher <sspeiche@gmail.com>",
"license": "", "license": "",
"bugs": { "bugs": {
"url": "http://github.com/bettiolo/node-echo/issues" "url": "http://github.com/openshift/nodejs-ex/issues"
}, },
"homepage": "http://apilb.com" "homepage": "http://github.com/openshift/nodejs-ex"
} }

View file

@ -1,12 +1,15 @@
var util = require('util'); var util = require('util');
var http = require('http');
var url = require('url'); var url = require('url');
var qs = require('querystring'); var qs = require('querystring');
var os = require('os') var os = require('os')
var port = process.env.PORT || process.env.port || process.env.OPENSHIFT_NODEJS_PORT || 8080; var port = process.env.PORT || process.env.port || process.env.OPENSHIFT_NODEJS_PORT || 8080;
var ip = process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; var ip = process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0';
var nodeEnv = process.env.NODE_ENV || 'unknown'; var nodeEnv = process.env.NODE_ENV || 'unknown';
var server = http.createServer(function (req, res) {
var express = require('express');
var app = express();
app.use(function(req, res, next) {
var url_parts = url.parse(req.url, true); var url_parts = url.parse(req.url, true);
var body = ''; var body = '';
@ -43,8 +46,9 @@ var server = http.createServer(function (req, res) {
res.write('OS CPU model: ' + os.cpus()[0].model + '\n'); res.write('OS CPU model: ' + os.cpus()[0].model + '\n');
res.write('OS CPU speed: ' + os.cpus()[0].speed + 'mhz\n'); res.write('OS CPU speed: ' + os.cpus()[0].speed + 'mhz\n');
res.end('\n'); res.end('\n');
}); });
next();
}); });
server.listen(port);
app.listen(port, ip);
console.log('Server running on ' + ip + ':' + port); console.log('Server running on ' + ip + ':' + port);

View file

@ -1,17 +0,0 @@
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<iisnode loggingEnabled="false" />
<rewrite>
<rules>
<rule name="myapp">
<match url="/*" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>