diff --git a/templates/app.js b/templates/app.js index c8637a1c..f7eff0e9 100644 --- a/templates/app.js +++ b/templates/app.js @@ -135,8 +135,8 @@ app.enableAuth(); * (only if this module is the main module) */ -if(require.main === module) { - require('http').createServer(app).listen(app.get('port'), app.get('host'), +app.start = function() { + return require('http').createServer(app).listen(app.get('port'), app.get('host'), function(){ var baseUrl = 'http://' + app.get('host') + ':' + app.get('port'); if (explorerConfigured) { @@ -150,3 +150,7 @@ if(require.main === module) { } ); } + +if(require.main === module) { + app.start(); +} diff --git a/templates/package.js b/templates/package.js index b05a7df9..4c7275fa 100644 --- a/templates/package.js +++ b/templates/package.js @@ -1,6 +1,7 @@ module.exports = { "version": "0.0.0", "main": "app.js", + "bin": "server.js", "scripts": { "start": "node app.js" }, diff --git a/templates/server.js b/templates/server.js new file mode 100755 index 00000000..0287d506 --- /dev/null +++ b/templates/server.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +require('./').start();