Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Server.js generation to make it not required to run the server with lcm. #84

Merged
merged 1 commit into from

3 participants

@xxblakefailxx

...the package.json main. Fix for Issue #75.

On a side note if not running through lcm and just using node in the directory it will run with defaults, you can also run from nodemon directly now. nodemon project 1337 would load the project in nodemon using port 1337.

@hsingh23

+1
I've tested it manually and it works. This is really needed if you want to deploy on appfog as you need to be able to set the env variables such as port and host before starting server.

@adityamukho adityamukho referenced this pull request from a commit in adityamukho/locomotive-drywall-seed
@adityamukho adityamukho Added server.js (jaredhanson/locomotive#84) 3c06635
@jaredhanson jaredhanson merged commit 7ee549b into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 30, 2013
  1. @xxblakefailxx

    Added to lcm create method to generate a server.js file and add this …

    xxblakefailxx authored
    …to the package.json main. Fix for Issue #75.
This page is out of date. Refresh to see the latest.
Showing with 20 additions and 1 deletion.
  1. +20 −1 lib/locomotive/cli/create.js
View
21 lib/locomotive/cli/create.js
@@ -194,11 +194,29 @@ var packageJSON = [
, ' "express": "3.x.x",'
, ' "connect-powered-by": "0.1.x",'
, ' "ejs": "0.8.x"'
- , ' }'
+ , ' },'
+ , ' "main": "./server.js"'
, '}'
, ''
].join(eol);
+var serverJS = [
+ 'var locomotive = require(\'locomotive\'),'
+ , ' env = process.env.NODE_ENV || \'development\','
+ , ' port = process.argv[2] || process.env.PORT || 3000,'
+ , ' address = \'0.0.0.0\';'
+ , ''
+ , 'console.log(process.argv);'
+ , ''
+ , 'locomotive.boot(__dirname, env, function(err, server) {'
+ , ' if (err) { throw err; }'
+ , ' server.listen(port, address, function() {'
+ , ' var addr = this.address();'
+ , ' console.log(\'listening on %s:%d\', addr.address, addr.port);'
+ , ' });'
+ , '});'
+ , ''
+].join(eol);
/**
* Create application at the given directory `path`.
@@ -246,6 +264,7 @@ function createApplicationAt(path) {
});
write(path + '/package.json', packageJSON);
+ write(path + '/server.js', serverJS);
});
}
Something went wrong with that request. Please try again.