1

I'm having trouble setting up my www file, the file responsible for running my application both in my development environment, such as the production environment.

I'm constantly developing new things for my application on my development environment, then sending for the production, and I would like to set up my file responsible for creating the server and make it run in a dynamic way, without changing all the time that i need send to the production.

What I need is to make the following code to understand what environment the application is and apply the correct settings, without having to be manually.

This is the code that i am using in my development environment:

var app = require('../app');
var debug = require('debug')('myapp');
var http = require('http');

var server = http.createServer(app);

server.listen(3000, "0.0.0.0", function() {
  var addr = server.address();
  debug('Running on port ' + addr.address + ':' + addr.port);
});
Dimitri Dewaele
  • 10,311
  • 21
  • 80
  • 127

1 Answers1

0

Since you're already using the debug module, you should be able to simply check debug.enabled to know if you're in "debug mode."

mscdex
  • 104,356
  • 15
  • 192
  • 153
  • this is not my question @mscdex.. i want organize the create server to work both in the dev/prod environments.. –  Feb 08 '15 at 04:20
  • 1
    Work *how*? What exactly is the difference between the two that you're trying to abstract? – mscdex Feb 08 '15 at 04:22