web-app-runner
Advanced tools
Comparing version 0.90.26 to 0.90.27
@@ -12,2 +12,3 @@ /** | ||
var config = { | ||
appkey:'d551900c-146a-11e4-aaa3-df58755e84a9', | ||
env:'staging', | ||
@@ -14,0 +15,0 @@ port:3005, |
@@ -26,3 +26,4 @@ /** | ||
daemon = dash.isBoolean( options.daemon ) ? options.daemon : false, | ||
app = options.app; | ||
app = options.app, | ||
connection; | ||
@@ -39,2 +40,4 @@ /** | ||
app.use( ipfilter.authorize ); | ||
app.use( server.shutdown ); | ||
app.use( server.logger ); | ||
@@ -59,3 +62,3 @@ | ||
log.info('listening on port: ', port, ', from home: ', home, ', with env: ', env); | ||
app.listen( port ); | ||
connection = app.listen( port ); | ||
}; | ||
@@ -88,2 +91,45 @@ | ||
this.shutdown = function(request, response, next) { | ||
var method = request.method, | ||
url = request.url, | ||
ip = request.ip, | ||
msg = 'shutting down from pid: ' + process.pid; | ||
log.info('shutdown request from ip: ', ip, ', url: ', url); | ||
if (url === '/shutdown') { | ||
response.writeHead(200, { | ||
'Content-Length': msg.length, | ||
'Content-Type': 'text/plain' | ||
}); | ||
response.end( msg, function(err) { | ||
log.info('sent, now closing...'); | ||
process.nextTick( server.stop ); | ||
}); | ||
} else { | ||
log.info('no shutdown...'); | ||
next(); | ||
} | ||
}; | ||
/** | ||
* stop the service; override this to implement a shutdown hook | ||
*/ | ||
this.stop = function() { | ||
if (app) { | ||
log.info('closing connection...'); | ||
connection.close(); | ||
} else { | ||
log.warn('stop called but app is null...'); | ||
} | ||
}; | ||
/** | ||
* standard logger outputs the visitor in json | ||
* | ||
* @param request | ||
* @param response | ||
* @param next | ||
*/ | ||
this.logger = function(request, response, next) { | ||
@@ -107,3 +153,4 @@ var visitor = request.visitor; | ||
child, | ||
command; | ||
command, | ||
filename; | ||
@@ -122,2 +169,4 @@ args.shift(); | ||
// now write the pid to process-port.pid | ||
filename = server.createProcessPIDFile(); | ||
} | ||
@@ -128,2 +177,3 @@ }; | ||
return { | ||
port:port, | ||
runInstance:runInstance | ||
@@ -130,0 +180,0 @@ }; |
{ | ||
"name": "web-app-runner", | ||
"version": "0.90.26", | ||
"version": "0.90.27", | ||
"description": "A simple HTTP application server that accepts or rejects connections based on authenticated attributes including ip, user agent, etc. The server can be used stand alone or as middleware for connect or express.", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -199,2 +199,2 @@ # Web App Runner | ||
- - - | ||
<p><small><em>Copyright © 2014, rain city software | Version 0.90.26</em></small></p> | ||
<p><small><em>Copyright © 2014, rain city software | Version 0.90.27</em></small></p> |
@@ -15,2 +15,4 @@ /** | ||
log.setLevel('fatal'); | ||
var createOptions = function() { | ||
@@ -20,3 +22,4 @@ var opts = {}; | ||
opts.log = log; | ||
opts.port = 9999; | ||
opts.port = dash.random( 1000, 20000 ); | ||
opts.piddir = '/tmp'; | ||
@@ -33,2 +36,4 @@ return opts; | ||
'landingPageRouter', | ||
'shutdown', | ||
'stop', | ||
'__protected' | ||
@@ -35,0 +40,0 @@ ]; |
@@ -6,6 +6,10 @@ # Web App Runner To Do List | ||
* complete daemon runner by writing pid to process-port.pid file in the bin folder | ||
* implement stop.js by reading the process-port.pid file(s) and sending a kill message | ||
* add visitor middleware to pull ip, url, method, agent, etc? | ||
* add shutdown hook: http://127.0.0.1:port/shutdown?token=appkey | ||
* add a process status hook: /status?token=appkey | ||
* create separage middleware delegate as factory | ||
* implement stop.js [port][all] | ||
* implement dynamic filter read capability | ||
* add status.js to read the process pid and report status? | ||
* add Logger to enable creating category logger | ||
* modify to use socket logger for multiple servers | ||
@@ -12,0 +16,0 @@ * implement agent filter |
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
50856
747