diff --git a/NEWS.md b/NEWS.md index f16f28c6..3412e400 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,8 @@ Enhancements: - Change some http status responses to be more appropriate to the case - Forbid using map signatures of foreign users (#172) - Forbid instanciating templates of foreign users (#173) + - Allow passing environment configuration name via NODE_ENV to app.js + - Print environment configuration name on app start Bug fixes: diff --git a/app.js b/app.js index 444ffc40..fc877740 100755 --- a/app.js +++ b/app.js @@ -8,11 +8,16 @@ */ +if ( process.argv[2] ) ENV = process.argv[2]; +else if ( process.env['NODE_ENV'] ) ENV = process.env['NODE_ENV']; +else ENV = 'development'; + +process.env['NODE_ENV'] = ENV; + // sanity check -var ENV = process.argv[2] if (ENV != 'development' && ENV != 'production' && ENV != 'staging' ){ console.error("\nnode app.js [environment]"); - console.error("environments: [development, production, staging]\n"); + console.error("environments: development, production, staging\n"); process.exit(1); } @@ -49,7 +54,9 @@ ws.maxConnections = global.environment.maxConnections || 128; ws.listen(global.environment.port, global.environment.host); ws.on('listening', function() { - console.log("Windshaft tileserver started on " + global.environment.host + ':' + global.environment.port); + console.log("Windshaft tileserver started on " + + global.environment.host + ':' + global.environment.port + + " (" + ENV + ")"); }); // DEPRECATED, use SIGUSR2