NodeJS Dynamically Load server instancess for a socket using socket.io

i have the next files structure:

app.js - Server

data
    |__ config.txt   -  configuration
    |__ logs

srv
    |__ ticket.js    - ticket server
    |__ game.js      - game server

app.js read from 'config.txt' the servers to load and run

config.txt

port=7891
servers=ticket

servers also could be: servers=ticket,game

ticket.js

var init = function(io) {
    return io.of('/ticket')
    .on('connection', function (socket) {

        socket.on('message', function () { 

        });

        socket.on('disconnect', function () { 

        });

    });
};

module.exports = init;

app.js

//
//  Requires
//
var _ = require('underscore')._;

var fs = require('fs');
var io = require('socket.io');
var logger = require('./mod/log.js');

//
//  Configuration
//

var options = {
    port: 6789,
    modules: [],
    servers: []
};

// Reads config.txt and insert values into "var options"
if(fs) {
    var config = fs.readFileSync("data/config.txt").toString().replace("\r\n", "\n").split("\n");
    var line, t, val;

    for(i in config) {
        if(config[i].indexOf("=") === -1)
            continue;

        line = config[i].split("=");
        t = Object.prototype.toString.call(options[line[0]]);
        t = t.slice(t.indexOf(" ")+1, t.length-1).toLowerCase();

        switch(t) {
            case 'number':
                val = parseInt(line[1]);
            break;

            case 'array':
                val = line[1].replace(", ", ",").split(",");
            break;

            default:
                val = line[1];
            break;
        }

        options[line[0]] = val;
    }

    logger.info("Configuration loaded");
    logger.info(options);

    io = io.listen(options.port);
}

// Starts all servers specified into config.txt
for(var i in options.servers) {
    logger.info("Starting server: "+options.servers[i]);

    var sv = require('./srv/'+ options.servers[i] + '.js');
    logger.info('./srv/'+ options.servers[i] + '.js');
    sv.init(io); //< HERE THROWS THE ERROR (*)

    logger.info("Ready");
}

(*) The error is the next:

2013-06-24T04:16:47.513Z - error: uncaughtException: Object function (io) { return io.of('/ticket') .on('connection', function (socket) {

            socket.on('message', function () {

            });

            socket.on('disconnect', function () {

            });

    }); }  has no method 'init' date=Mon Jun 24 2013 01:16:47 GMT-0300 (Hora estándar de Argentina), pid=3316, uid=null, gid=null,

cwd=C:\Users\LUCIANO\Svn\Dropbox\Propi os\WebGamePlatform\trunk\Development\NodeJSServer, execPath=C:\Program Files (x8 6)\nodejs\node.exe, version=v0.10.8, argv=[node, C:\Users\LUCIANO\Svn\Dropbox\Pr opios\WebGamePlatform\trunk\Development\NodeJSServer\app.js], rss=19689472, heap Total=10243584, heapUsed=5332216, loadavg=[0, 0, 0], uptime=14388.1320351, trace =[column=5, file=C:\Users\LUCIANO\Svn\Dropbox\Propios\WebGamePlatform\trunk\Deve lopment\NodeJSServer\app.js, function=, line=60, method=null, native=false, colu mn=26, file=module.js, function=Module._compile, line=456, method=_compile, nati ve=false, column=10, file=module.js, function=Object.Module._extensions..js, lin e=474, method=Module._extensions..js, native=false, column=32, file=module.js, f unction=Module.load, line=356, method=load, native=false, column=12, file=module .js, function=Function.Module._load, line=312, method=Module._load, native=false , column=10, file=module.js, function=Function.Module.runMain, line=497, method= Module.runMain, native=false, column=16, file=node.js, function=startup, line=11 9, method=null, native=false, column=3, file=node.js, function=null, line=901, m ethod=null, native=false], stack=[TypeError: Object function (io) { , return io.of('/ticket') ,
.on('connection', function (socket) { , ,
socket.on('message', function () { , , }); , ,
socket.on('disconnect', function () { , , }); , ,
});

How can i fix this?

You are exporting a function, and not an object. This means that the correct call should be sv(io) and not sv.init(io).
If you want to expose the init function, you have to use module.exports.init = init.