title: Switching NodeJs application to debug mode from within it's process
body: <p>I have a NodeJs module "some-module" that I want to have installed globally so it can be run directly from the command line without the node executable prefix. ie: <code>$&gt; some-module [args]</code> I would like one of those arguments to be <code>--debug</code>. The reasoning for this is that I don't want to require users of this module to install it to their local directory just to run <code>node --debug-brk node_modules/some-module/[path to entry point] [args]</code>. </p>
  
  <p>The NodeJs documentation states in it's advanced usages section on debugging (<a href="http://nodemanual.org/latest/nodejs_ref_guide/debugging.node.js.html" rel="nofollow">http://nodemanual.org/latest/nodejs_ref_guide/debugging.node.js.html</a>)</p>
  
  <blockquote>
    <p>The V8 debugger can be enabled and accessed either by starting Node.js with the <code>--debug</code> command-line flag or by signaling an existing Node.js process with <code>SIGUSR1</code>.</p>
  </blockquote>
  
  <p>I tried doing this with:</p>
  
  <pre><code>process.kill(process.pid, 'SIGUSR1');
  </code></pre>
  
  <p>Which produced the error:</p>
  
  <pre><code>node.js:201
          throw e; // process.nextTick error, or 'error' event on first tick
                ^
  Error: Unknown signal: SIGUSR1
      at EventEmitter.kill (node.js:366:17)
      at Object.&lt;anonymous&gt; (c:\dev\some-module\app.js:94:17)
      at Module._compile (module.js:441:26)
      at Object..js (module.js:459:10)
      at Module.load (module.js:348:31)
      at Function._load (module.js:308:12)
      at Array.0 (module.js:479:10)
      at EventEmitter._tickCallback (node.js:192:40)
  </code></pre>
  
  <p>What do I need to do to get the running process switched to debug mode?</p>
  
  <p>Also, I would like to debug the given application with node-inspector.</p>