#!/usr/bin/env node

module.exports = function MVC(app){
    var NODE_DOMAIN, fs, _
    // NODE_DOMAIN = require('domain').create()
    // NODE_DOMAIN.on('error', function (err) { console.log(err.message, err.stack) })
    // NODE_DOMAIN.run(function(){

    _ = require('lodash-node')
    _.chokidar = require('chokidar')
    fs = require('fs')

    _.extend(_, require('e_helpers_io'))
    _.extend(_, require('e_helpers_path'))
    _.extend(_, require('e_helpers_process'))
    _.extend(_, require('e_helpers_typecheck'))
    _.log = _.noop

    _.watch = function(file, cb){
        function reload(err, data){
            if (err) throw err
            _.log('file updated: '+file)
            cb(data)
        }
        _.chokidar
        .watch(file, {persistent: true})
        .on('change', function(){
            fs.readFile(file, reload)
        })
    }

    var settings = this.settings = require('e_settings')
    var easyioc = require('easyioc')
    var router = require('runway')

    function adapt(module){
        return (_.isString(module))
            ? function(){ return require(module) }
            : function(){ return module }
    }

    easyioc
        .add( '_',               adapt(_)               )
        .add( 'router',          adapt(router)          )
        .add( 'ioc',             adapt(easyioc)         )
        .add( 'fetchfiles',      adapt('filefetcher')   )
        .add( 'RESTController',  adapt('e_controllers') )
        .add( 'views',           'e_views'              )
        .add( 'templating',      settings.templates     )
        .add( 'settings',        settings               )
        .add( 'main',            app                    )
        .exec()

    var server = require('http').createServer(router.listener)
    server.listen( settings.port, null )
}

@@ -1151,24 +1151,88 @@
 le %7D%0A    %7D%0A%0A
+    var server = require('http').createServer(router.listener)%0A%0A
     easyioc%0A
@@ -1710,20 +1710,22 @@
  .add( '
-main
+server
 ',      
@@ -1732,13 +1732,16 @@
     
-  app
+server  
     
@@ -1755,134 +1755,82 @@
     
+)%0A
      
-)%0A
    
-     .exec()%0A%0A    var server = require('http').createServer(router.listener)%0A    server.listen( settings.port, null 
+.add( 'main',            app                    )%0A        .exec(
 )%0A%7D%0A

Remove server.listen() from main.js, provide server object to developer instead.