javascript - NodeJS / ExpressJS Multiple environments simulatenously -


my nodejs project requires multiple environments. e.g. sit/qa/prod. have set config files (e.g. qa.js) specify port use , db etc. start script sets node_env according environment, , launch doing "npm start".

this works fine single environment, starts on port should , fine. however, when start environment, first stops working. assume either fact node_env has changed, or else? node_env matter when first run npm start or after too?

can please advise how have multiple environments simultaneously running?

an environment (almost) nothing special express. can use selection mechanism set configuration based on value of node_env, you're doing now.

conceptually, should think of this:

if (node_env === 'qa') {   // set configuration qa } else if (node_env === 'production') {   // set configuration production } else   // set configuration development/testing/... } 

as can see, implies can use 1 environment @ time. if set production environment, use configuration environment, and nothing else.

running multiple environments simultanously in single process defeats whole purpose of node_env. however, can—to degree—run multiple different versions of app, each 1 running in separate environment (below assumes you're using sort of unix environment):

// start qa version $ env node_env=qa npm start  // in window, start production version $ env node_env=production npm start 

i "to degree", because it's not possible have 2 different processes listening on same tcp port. environments need take account (for instance, have qa instance listen on port 3000 , production instance on 3001).


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -