node.js오류 다시 올립니다 ㅜㅜ 이미지깨짐으로인해 채택완료
여기다 질문해도 되는지 모르겠지만.. 그래도 여기는 유능한 분들이 많아서.. 올려 보겠습니다.

</span></div><div class="NHN_Writeform_Main" style="color: rgb(72, 72, 72); font-size: 14.004px; letter-spacing: -0.01px; line-height: 25.2072px; font-family: dotum;"><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">var fs = require('fs');</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">var Metrics = require('./metrics');</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">var ProductionConfig = require('./productionconfig');</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">var _ = require('underscore');</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">function main(config) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var Log = require('log');</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> switch(config.debug_level) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> case "error":</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> log = new Log(Log.ERROR); break;</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> case "debug":</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> log = new Log(Log.DEBUG); break;</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> case "info":</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> log = new Log(Log.INFO); break;</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> };</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var production_config = new ProductionConfig(config);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> if(production_config.inProduction()) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> _.extend(config, production_config.getProductionSettings());</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> }</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var ws = require("./ws");</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var WorldServer = require("./worldserver");</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var server = new ws.WebsocketServer(config.port, config.use_one_port, config.ip);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var metrics = config.metrics_enabled ? new Metrics(config) : null;</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var worlds = [];</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var lastTotalPlayers = 0;</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var DatabaseSelector = require("./databaseselector");</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var checkPopulationInterval = setInterval(function() {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> if(metrics && metrics.isReady) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> metrics.updateWorldCount();</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> metrics.getTotalPlayers(function(totalPlayers) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> if(totalPlayers !== lastTotalPlayers) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> lastTotalPlayers = totalPlayers;</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> _.each(worlds, function(world) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> world.updatePopulation(totalPlayers);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> }</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> }</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> }, 1000);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> log.info("Starting BrowserQuest game server...");</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var selector = DatabaseSelector(config);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> databaseHandler = new selector(config);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> server.onConnect(function(connection) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var world; // the one in which the player will be spawned</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var connect = function() {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> if(world) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> world.connect_callback(new Player(connection, world, databaseHandler));</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> }</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> };</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> if(metrics) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> metrics.getOpenWorldCount(function(open_world_count) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> // choose the least populated world among open worlds</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> world = _.min(_.first(worlds, open_world_count), function(w) { return w.playerCount; });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> connect();</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> }</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> else {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> // simply fill each world sequentially until they are full</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> world = _.find(worlds, function(world) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> return world.playerCount < config.nb_players_per_world;</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> world.updatePopulation();</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> connect();</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> }</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> server.onError(function() {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> log.error(Array.prototype.join.call(arguments, ", "));</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var onPopulationChange = function() {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> metrics.updatePlayerCounters(worlds, function(totalPlayers) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> _.each(worlds, function(world) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> world.updatePopulation(totalPlayers);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> metrics.updateWorldDistribution(getWorldDistribution(worlds));</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> };</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> _.each(_.range(config.nb_worlds), function(i) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var world = new WorldServer('world'+ (i+1), config.nb_players_per_world, server, databaseHandler);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> world.run(config.map_filepath);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> worlds.push(world);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> if(metrics) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> world.onPlayerAdded(onPopulationChange);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> world.onPlayerRemoved(onPopulationChange);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> }</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> server.onRequestStatus(function() {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> return JSON.stringify(getWorldDistribution(worlds));</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> if(config.metrics_enabled) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> metrics.ready(function() {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> onPopulationChange(); // initialize all counters to 0 when the server starts</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> }</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> process.on('uncaughtException', function (e) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> // Display the full error stack, to aid debugging</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> log.error('uncaughtException: ' + e.stack);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">}</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">function getWorldDistribution(worlds) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> var distribution = [];</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> _.each(worlds, function(world) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> distribution.push(world.playerCount);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> return distribution;</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">}</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">function getConfigFile(path, callback) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> fs.readFile(path, 'utf8', function(err, json_string) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> if(err) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> console.info("This server can be customized by creating a configuration file named: " + err.path);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> callback(null);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> } else {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> callback(JSON.parse(json_string));</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> }</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">}</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">var defaultConfigPath = './server/config.json';</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">var customConfigPath = './server/config_local.json';</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">process.argv.forEach(function (val, index, array) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> if(index === 2) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> customConfigPath = val;</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> }</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">});</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;">
</div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">getConfigFile(defaultConfigPath, function(defaultConfig) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> getConfigFile(customConfigPath, function(localConfig) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> if(localConfig) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> main(localConfig);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> } else if(defaultConfig) {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> main(defaultConfig);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> } else {</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> console.error("Server cannot start without any configuration file.");</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> process.exit(1);</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> }</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;"> });</span></div><div class="NHN_Writeform_Main" style="color: rgb(0, 0, 0); font-size: 12px; letter-spacing: normal; line-height: 18px;"><span style="font-size: 8pt;">});</span></div><div><span style="font-size: 8pt;">
답변 9개
npm install or update라고 치는 것이 아니고..
npm install 해보시던지..
아니면 npm update 둘중에 하나만 하라는 이야기입니다.
노드 책을 보시고 시작하라고 권하고 싶네요..
답변에 대한 댓글 2개
그 node.js bcrypt 모듈이 없는데. 어디서 구해야 될까요;; npm으로 설치하면 에러가 떠서;;
댓글을 작성하려면 로그인이 필요합니다.
npm install bcrypt 하시면 되고요..
없다고 하는 모듈은 대부분 위와 같은 형식으로 설치하시면 됩니다.
대부분의 연관된 파일은 packages.json에 들어가 있습니다. (없다면 여기다 추가)
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
모든 파일이 d 디렉토리 밑에 있네요..
cd /users/pc/d
npm install or npm update 하시고
node server 해보세요
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.

참고로 말씀드리면 http://uwooto.blogspot.kr/2014/09/nodejs-broswer-quest-windows.html">http://uwooto.blogspot.kr/2014/09/nodejs-broswer-quest-windows.html
여기나와 있는 설치법대로 하였으며 틀리게 한부분이 있다면
log bison websocket websocket-server sanitizer memcache 이모듈들은 설치가 안되있습니다.
underscore 이것만 설치 했고 다른건 설치오류가 나와 설치하지 못했습니다.
댓글을 작성하려면 로그인이 필요합니다.
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변에 대한 댓글 2개
댓글을 작성하려면 로그인이 필요합니다.
메시지가
configuration file없이는 실행할수가 없다고 하니..
var defaultConfigPath = './server/config.json'; |
| var customConfigPath = './server/config_local.json'; |
2가지 파일이 있는지 체크 해보세요..
path는 풀 path 보다는 그냥 모든 파일이 있는 곳에서 실행하는 것으로 해보세요..
node js/main.js 식으로..
현디렉토리안에 모든 구성이 있어야 겠죠..
물론 server 디렉토리안에 위의 json파일 2개가 있어야 겠죠..
답변에 대한 댓글 1개
var customConfigPath = './server/config_local.json';
위 두가지 파일은 server디렉토리안에 다 있습니다..
있는데도 안되네요 ㅜㅜ
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인



근데 안되서;; npm install or update 까지도 처보았습니다 ㅜㅜ