             console.error err.stack
             res.send 500, 'Something broke!'
 
+        @enableSocketRedirection()
         @setControllers()
 
     setControllers: ->


    constructor: ->
        @app = express()
        @proxy = new httpProxy.RoutingProxy()
        @proxy.source.port = 9104
        @userManager = new UserManager()
        @instanceManager = new InstanceManager()

        res.send error: true, msg: msg, code

    ### Routes ###

    # enable websockets
    # this is safe with socket.io, not sure if still safe with plain Websockets
    enableSocketRedirection: =>
        @server.on 'upgrade', (req, socket, head) =>
            slug = @app._router.matchRequest(req).params.name # @dirtyhack ?
            req.url = req.url.replace "/apps/#{slug}", ''
            @proxy.proxyWebSocketRequest req, socket, head,
                host: 'localhost',
                port: @routes[slug] # @FIXME after merge with feature.multiple

    # Default redirection send requests to home.
    defaultRedirectAction: (req, res) =>
