Permalink
Browse files

allow loading of server/ as well as server.js

  • Loading branch information...
1 parent d6f65ff commit 857d7d65673dde4a1980b901172a48e131a26d1c @coolaj86 committed May 28, 2012
Showing with 35 additions and 10 deletions.
  1. +26 −0 bin/server.js
  2. +9 −10 server.js
View
@@ -0,0 +1,26 @@
+/*jshint strict:true node:true es5:true onevar:true laxcomma:true laxbreak:true*/
+(function () {
+ "use strict";
+
+ var app = require('../server.js')
+ ;
+
+ function run() {
+ var config = require('../config')
+ , port = process.argv[2] || config.port || 4080
+ , server
+ ;
+
+ function listening() {
+ console.info('Listening on ' + server.address().address + ':' + server.address().port);
+ }
+
+ server = app.listen(port, listening);
+ }
+
+ if (require.main === module) {
+ console.info("\n=== connect-vhoster running in stand-alone mode ===\n");
+ run();
+ }
+
+}());
View
@@ -1,3 +1,4 @@
+/*jshint strict:true node:true es5:true onevar:true laxcomma:true laxbreak:true*/
(function () {
"use strict";
@@ -33,9 +34,9 @@
function eachHost(hostname) {
var serverPath = path.join(dirname, hostname)
- , aliases = serverPath + '/aliases.js'
- , server = serverPath + '/server.js'
- , app = serverPath + '/app.js'
+ , aliases = serverPath + '/aliases'
+ , server = serverPath + '/server'
+ , app = serverPath + '/app'
, hostnames
, stats
;
@@ -56,7 +57,7 @@
}
if (!/\./.exec(hostname)) {
- hostname += (config.defaultDomain)
+ hostname += (config.defaultDomain);
}
try {
@@ -91,7 +92,7 @@
} catch(e) {
hostnames = [];
}
- hostnames.push(hostname)
+ hostnames.push(hostname);
hostnames.forEach(eachHostname);
}
@@ -142,15 +143,13 @@
console.info('Listening on ' + server.address().address + ':' + server.address().port);
}
- if (port) {
- server = app.listen(port, listening);
- } else {
- server = app.listen(listening);
- }
+ server = app.listen(port, listening);
}
if (require.main === module) {
console.info("\n=== connect-vhoster running in stand-alone mode ===\n");
run();
}
+
+ module.exports = create(__dirname + '/vhosts');
}());

0 comments on commit 857d7d6

Please sign in to comment.