Permalink
Browse files

Merge branch 'debug-support' of https://github.com/goddyZhao/locomotive

… into debug-support
  • Loading branch information...
2 parents 6f692ab + ce6ca23 commit e3be47d3a6940deabd22eb44cb21faa6c173f8c8 @jaredhanson committed Apr 1, 2012
Showing with 26 additions and 2 deletions.
  1. +7 −0 README.md
  2. +18 −2 bin/lcm.js
  3. +1 −0 bin/server.js
View
@@ -27,6 +27,13 @@ Start the server.
The application is available at [localhost:3000](http://localhost:3000).
+Start the server with node debug mode
+
+ $ lcm server --debug (node --debug mode)
+ $ lcm server --debug-brk (node --debug-brk mode)
+
+Then you can use debug tools like [node-inspector](https://github.com/dannycoates/node-inspector) to debug your application as usual.
+
## Guide
The [Locomotive Guide](http://locomotivejs.org/guide/) is the official source
View
@@ -5,7 +5,10 @@ var program = require('commander')
program.version(locomotive.version)
.option('-a, --app [directory]', 'load app at specified directory (default: <working-dir>)')
- .option('-p, --port [number]', 'listen on specified port (default: 3000)');
+ .option('-p, --port [number]', 'listen on specified port (default: 3000)')
+ .option('--debug', 'enable node debug mode')
+ .option('--debug-brk', 'enable node debug-brk mode')
+ .option('--debug-port [number]', 'debug app on specified port(default: 5858)');
program.command('create')
.description('-> create Locomotive application')
@@ -16,7 +19,20 @@ program.command('create')
program.command('server')
.description('-> start the Locomotive server')
.action(function() {
- locomotive.cli.server(program.app || process.cwd(), program.port || 3000);
+ var debug = program.debug || program.debugBrk;
+ if(debug){
+ var debugMode = program.debug ? "--debug" : "--debug-brk"
+ , filePath = require("path").join(__dirname, "server.js")
+ , command = ["node ", debugMode, " ", filePath].join("");
+
+ require("child_process")
+ .exec(command,function(err, stdout, stderr){
+ if(err){ throw err; }
+ console.log(stdout);
+ });
+ }else{
+ locomotive.cli.server(program.app || process.cwd(), program.port || 3000);
+ }
});
program.parse(process.argv);
View
@@ -0,0 +1 @@
+require("../").cli.server(process.cwd(),"3000");

0 comments on commit e3be47d

Please sign in to comment.