테스트 사이트 - 개발 중인 베타 버전입니다

node.js 질문 채택완료

플로리아 9년 전 조회 1,794

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

 

 

http://cafefiles.naver.net/20151210_100/mocho_i_1449705599989JqGTR_PNG/%C1%A6%B8%F1_%BE%F8%C0%BD.png" src="http://cafefiles.naver.net/20151210_100/mocho_i_1449705599989JqGTR_PNG/%C1%A6%B8%F1_%BE%F8%C0%BD.png" width="640" height="377" style="width: 640px; height: 377px;">
이런 오류가 나오네요..
대충 파일을 읽을수 없다는거 같은데.. 파일 명은 config.json 과 config_local.json-dist 입니다.. config_local.json-dist같은경우 config_local.json로 변경후 해봐도 그대로네요 ㅜㅜ 
참고로 설치 중인 건broswer quset 라는 게임입니다. 모듈 설치를 따로 또해야되는게 있는건지 아니면
다른 설정을 해야되는건지.. 알려주세요
참고로 맨 밑부분을 말씀 드리는겁니다 . node d/server/js/main.js  밑
참고로 main.js 소스는 밑 참고 해주세요
</div><div class="NHN_Writeform_Main" style="font-family: dotum;"><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">var fs = require('fs');</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">var Metrics = require('./metrics');</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">var ProductionConfig = require('./productionconfig');</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">var _ = require('underscore');</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">function main(config) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    var Log = require('log');</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    switch(config.debug_level) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        case "error":</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            log = new Log(Log.ERROR); break;</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        case "debug":</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            log = new Log(Log.DEBUG); break;</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        case "info":</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            log = new Log(Log.INFO); break;</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    };</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    var production_config = new ProductionConfig(config);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    if(production_config.inProduction()) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        _.extend(config, production_config.getProductionSettings());</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    }</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    var ws = require("./ws");</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    var WorldServer = require("./worldserver");</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    var server = new ws.WebsocketServer(config.port, config.use_one_port, config.ip);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    var metrics = config.metrics_enabled ? new Metrics(config) : null;</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    var worlds = [];</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    var lastTotalPlayers = 0;</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    var DatabaseSelector = require("./databaseselector");</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    var checkPopulationInterval = setInterval(function() {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        if(metrics && metrics.isReady) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            metrics.updateWorldCount();</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            metrics.getTotalPlayers(function(totalPlayers) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">                if(totalPlayers !== lastTotalPlayers) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">                    lastTotalPlayers = totalPlayers;</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">                    _.each(worlds, function(world) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">                        world.updatePopulation(totalPlayers);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">                    });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">                }</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        }</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    }, 1000);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    log.info("Starting BrowserQuest game server...");</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    var selector = DatabaseSelector(config);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    databaseHandler = new selector(config);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    server.onConnect(function(connection) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        var world; // the one in which the player will be spawned</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        var connect = function() {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">                if(world) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">                    world.connect_callback(new Player(connection, world, databaseHandler));</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">                }</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            };</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        if(metrics) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            metrics.getOpenWorldCount(function(open_world_count) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">                // choose the least populated world among open worlds</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">                world = _.min(_.first(worlds, open_world_count), function(w) { return w.playerCount; });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">                connect();</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        }</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        else {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            // simply fill each world sequentially until they are full</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            world = _.find(worlds, function(world) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">                return world.playerCount < config.nb_players_per_world;</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            world.updatePopulation();</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            connect();</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        }</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    server.onError(function() {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        log.error(Array.prototype.join.call(arguments, ", "));</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    var onPopulationChange = function() {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        metrics.updatePlayerCounters(worlds, function(totalPlayers) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            _.each(worlds, function(world) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">                world.updatePopulation(totalPlayers);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        metrics.updateWorldDistribution(getWorldDistribution(worlds));</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    };</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    _.each(_.range(config.nb_worlds), function(i) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        var world = new WorldServer('world'+ (i+1), config.nb_players_per_world, server, databaseHandler);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        world.run(config.map_filepath);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        worlds.push(world);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        if(metrics) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            world.onPlayerAdded(onPopulationChange);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            world.onPlayerRemoved(onPopulationChange);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        }</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    server.onRequestStatus(function() {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        return JSON.stringify(getWorldDistribution(worlds));</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    if(config.metrics_enabled) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        metrics.ready(function() {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            onPopulationChange(); // initialize all counters to 0 when the server starts</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    }</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    process.on('uncaughtException', function (e) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        // Display the full error stack, to aid debugging</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        log.error('uncaughtException: ' + e.stack);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">}</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">function getWorldDistribution(worlds) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    var distribution = [];</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    _.each(worlds, function(world) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        distribution.push(world.playerCount);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    return distribution;</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">}</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">function getConfigFile(path, callback) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    fs.readFile(path, 'utf8', function(err, json_string) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        if(err) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            console.info("This server can be customized by creating a configuration file named: " + err.path);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            callback(null);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        } else {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            callback(JSON.parse(json_string));</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        }</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">}</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">var defaultConfigPath = './server/config.json';</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">var customConfigPath = './server/config_local.json';</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">process.argv.forEach(function (val, index, array) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    if(index === 2) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        customConfigPath = val;</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    }</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">});</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">getConfigFile(defaultConfigPath, function(defaultConfig) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    getConfigFile(customConfigPath, function(localConfig) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        if(localConfig) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            main(localConfig);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        } else if(defaultConfig) {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            main(defaultConfig);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        } else {</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            console.error("Server cannot start without any configuration file.");</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">            process.exit(1);</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">        }</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">    });</div><div class="NHN_Writeform_Main" style="font-size: 12px; line-height: 18px;">});</div><div><span style="font-size: 14.6667px;">
댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트
9년 전

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

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

 

 

로그인 후 평가할 수 있습니다

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

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

로그인