Allow using NODE_ENV env variable to determine app configuration

Default to "development" environment.
Forward NODE_ENV variable to childrens (for example, to hush
millstone).
This commit is contained in:
Sandro Santilli
2014-02-28 16:22:24 +01:00
parent c1a3cbc28c
commit ed5b045a15
2 changed files with 12 additions and 3 deletions
+2
View File
@@ -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:
+10 -3
View File
@@ -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