채택완료

node.js 질문

여기다 질문해도 되는지 모르겠지만.. 그래도 여기는 유능한 분들이 많아서.. 올려 보겠습니다.

 

 

%C1%A6%B8%F1_%BE%F8%C0%BD.png
이런 오류가 나오네요..
대충 파일을 읽을수 없다는거 같은데.. 파일 명은 config.json 과 config_local.json-dist 입니다.. config_local.json-dist같은경우 config_local.json로 변경후 해봐도 그대로네요 ㅜㅜ 
참고로 설치 중인 건broswer quset 라는 게임입니다. 모듈 설치를 따로 또해야되는게 있는건지 아니면
다른 설정을 해야되는건지.. 알려주세요
참고로 맨 밑부분을 말씀 드리는겁니다 . node d/server/js/main.js  밑

참고로 main.js 소스는 밑 참고 해주세요
Copy
var fs = require('fs');var Metrics = require('./metrics');var ProductionConfig = require('./productionconfig');var _ = require('underscore');function main(config) {    var Log = require('log');    switch(config.debug_level) {        case "error":            log = new Log(Log.ERROR); break;        case "debug":            log = new Log(Log.DEBUG); break;        case "info":            log = new Log(Log.INFO); break;    };    var production_config = new ProductionConfig(config);    if(production_config.inProduction()) {        _.extend(config, production_config.getProductionSettings());    }    var ws = require("./ws");    var WorldServer = require("./worldserver");    var server = new ws.WebsocketServer(config.port, config.use_one_port, config.ip);    var metrics = config.metrics_enabled ? new Metrics(config) : null;    var worlds = [];    var lastTotalPlayers = 0;    var DatabaseSelector = require("./databaseselector");    var checkPopulationInterval = setInterval(function() {        if(metrics && metrics.isReady) {            metrics.updateWorldCount();            metrics.getTotalPlayers(function(totalPlayers) {                if(totalPlayers !== lastTotalPlayers) {                    lastTotalPlayers = totalPlayers;                    _.each(worlds, function(world) {                        world.updatePopulation(totalPlayers);                    });                }            });        }    }, 1000);    log.info("Starting BrowserQuest game server...");    var selector = DatabaseSelector(config);    databaseHandler = new selector(config);    server.onConnect(function(connection) {        var world; // the one in which the player will be spawned        var connect = function() {                if(world) {                    world.connect_callback(new Player(connection, world, databaseHandler));                }            };        if(metrics) {            metrics.getOpenWorldCount(function(open_world_count) {                // choose the least populated world among open worlds                world = _.min(_.first(worlds, open_world_count), function(w) { return w.playerCount; });                connect();            });        }        else {            // simply fill each world sequentially until they are full            world = _.find(worlds, function(world) {                return world.playerCount < config.nb_players_per_world;            });            world.updatePopulation();            connect();        }    });    server.onError(function() {        log.error(Array.prototype.join.call(arguments, ", "));    });    var onPopulationChange = function() {        metrics.updatePlayerCounters(worlds, function(totalPlayers) {            _.each(worlds, function(world) {                world.updatePopulation(totalPlayers);            });        });        metrics.updateWorldDistribution(getWorldDistribution(worlds));    };    _.each(_.range(config.nb_worlds), function(i) {        var world = new WorldServer('world'+ (i+1), config.nb_players_per_world, server, databaseHandler);        world.run(config.map_filepath);        worlds.push(world);        if(metrics) {            world.onPlayerAdded(onPopulationChange);            world.onPlayerRemoved(onPopulationChange);        }    });    server.onRequestStatus(function() {        return JSON.stringify(getWorldDistribution(worlds));    });    if(config.metrics_enabled) {        metrics.ready(function() {            onPopulationChange(); // initialize all counters to 0 when the server starts        });    }    process.on('uncaughtException', function (e) {        // Display the full error stack, to aid debugging        log.error('uncaughtException: ' + e.stack);    });}function getWorldDistribution(worlds) {    var distribution = [];    _.each(worlds, function(world) {        distribution.push(world.playerCount);    });    return distribution;}function getConfigFile(path, callback) {    fs.readFile(path, 'utf8', function(err, json_string) {        if(err) {            console.info("This server can be customized by creating a configuration file named: " + err.path);            callback(null);        } else {            callback(JSON.parse(json_string));        }    });}var defaultConfigPath = './server/config.json';var customConfigPath = './server/config_local.json';process.argv.forEach(function (val, index, array) {    if(index === 2) {        customConfigPath = val;    }});getConfigFile(defaultConfigPath, function(defaultConfig) {    getConfigFile(customConfigPath, function(localConfig) {        if(localConfig) {            main(localConfig);        } else if(defaultConfig) {            main(defaultConfig);        } else {            console.error("Server cannot start without any configuration file.");            process.exit(1);        }    });});

|

답변 1개

채택된 답변
+20 포인트

이미지가 안나오는 것 같습니다. 

네이버의 이미지는 일반적으로 다른 곳에서 보이지 않게 설정되어 있습니다. ^^

 

 

답변을 작성하려면 로그인이 필요합니다.