Comparing version 0.1.11 to 0.1.12
@@ -5,2 +5,3 @@ var winston = require('winston'); | ||
var statsd = require('./statsd'); | ||
var cluster = require('cluster'); | ||
@@ -57,2 +58,13 @@ function _calcLogLevel(statusCode) { | ||
// var pid = cluster.isWorker ? cluster.worker.process.pid : process.pid; | ||
var user; | ||
if (req && req.session && req.session.passport && req.session.passport.user) { | ||
user = chalk.gray(req.session.passport.user); | ||
} | ||
else { | ||
user = chalk.red('anonymous'); | ||
} | ||
var msg = [ | ||
@@ -63,3 +75,4 @@ chalk.gray(req.method), | ||
req.originalUrl, | ||
chalk.gray(req && req.session && req.session.passport ? req.session.passport.user : '') | ||
user, | ||
// chalk.gray('pid=' + pid) | ||
].join(' '); | ||
@@ -66,0 +79,0 @@ |
@@ -28,3 +28,4 @@ 'use strict'; | ||
server: { | ||
port: 3000 | ||
port: 3000, | ||
cluster: false | ||
}, | ||
@@ -31,0 +32,0 @@ logger: null |
'use strict'; | ||
var http = require('http'), | ||
logger = require('./logger'); | ||
var http = require('http'); | ||
var cluster = require('cluster'); | ||
var numCPUs = require('os').cpus().length; | ||
var logger = require('./logger'); | ||
var startServer = function(done, app, options) { | ||
var h = http.createServer(app); | ||
h.listen(options.port); | ||
if (options.cluster) { | ||
if (cluster.isMaster) { | ||
// Fork workers. | ||
for (var i = 0; i < numCPUs; i++) { | ||
cluster.fork(); | ||
} | ||
logger.success('Started at http://localhost:' + options.port); | ||
cluster.on('exit', function(worker, code, signal) { | ||
logger.error('worker ' + worker.process.pid + ' died'); | ||
}); | ||
} | ||
else { | ||
// Workers can share any TCP connection | ||
// In this case its a HTTP server | ||
http.createServer(app) | ||
.listen(options.port); | ||
logger.query('Started worker pid: ' + cluster.worker.process.pid); | ||
} | ||
} | ||
else { | ||
var h = http.createServer(app); | ||
h.listen(options.port); | ||
logger.success('Started at http://localhost:' + options.port + ' (single core)'); | ||
} | ||
done(); | ||
@@ -13,0 +38,0 @@ }; |
{ | ||
"name": "elephas", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"description": "Some added sugar on top of express to give our our some sensible defaults and a little structure.", | ||
@@ -5,0 +5,0 @@ "main": "elephas.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29973
603