title: Node.js spawns multiple processes
body: <p>I got a little bit confused about my node.js application. As far as I thought, node.js runs in a single process. However if I start my application by invoking <code>node app.js</code>and monitor it with htop, I can see 4 sub-processes running, where I'd expect only one to be.</p>
  
  <p><img src="https://i.stack.imgur.com/Y1Idn.png" alt="enter image description here"></p>
  
  <p>app.js</p>
  
  <pre><code>var express = require('express'),
      routes = require('./routes'),
  
      objects = require('./objects'),
  
      http = require('http'),
      path = require('path'),
  
      pinLayout = objects.pinlayout,
  
      // utils
      util = require('util'),
      wiringPi = require('wiring-pi'),
      winston = require('winston'),
      async = require('async');
  
  
  // Logger - winston
  var log = new(winston.Logger)({
      transports: [
          new(winston.transports.Console)({
              colorize: true,
              timestamp: true
          }),
          new(winston.transports.File)({
              filename: './log/app.log'
          })
      ]
  });
  
  // WiringPi
  wiringPi.setup('gpio');
  
  var app = express();
  
  // all environments
  app.set('port', process.env.PORT || 3001);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  
  app.use(express.favicon());
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  
  app.use(require('less-middleware')({
      src: __dirname + '/public',
      force: true,
      compress: true
  }));
  
  app.use(app.router);
  app.use(express.static(path.join(__dirname, 'public')));
  
  // 404 Page
  app.use(function(req, res, next) {
      res.render('404.jade', {
          title: "404 - Page Not Found",
          showFullNav: false,
          status: 404,
          url: req.url
      });
  });
  
  // development only
  if ('development' == app.get('env')) {
      app.use(express.errorHandler({
          dumpExceptions: true,
          showStack: true
      }));
  }
  </code></pre>