Issues Setting Up Dedicated Server

Discussion in 'Work-In-Progress Mods' started by micah1711, June 19, 2016.

  1. micah1711

    micah1711 New Member

    Messages:
    3
    Likes Received:
    0
    Hello,

    Recently I follow Exodus Esport's guide on how to setup a dedicated PA server. I followed the instructions step by step on Ubuntu 14.04.3. Everything went well until I had to start up the server with the command " nodejs ./NodePAMaster/src/control.js". At this point I get the following message.


    undefined:2
    "server":b
    ^
    SyntaxError: Unexpected token b
    at Object.parse (native)
    at Object.<anonymous> (/home/micah1711/NodePAMaster/src/control.js:2:17)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3

    I am mostly a networking and computer hardware and virtualization guy. I have ok experience in linux and no experience in Java Script. Please help.

    Best Regards,

    Micah
  2. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,327
    Likes Received:
    2,125
    It kind of sounds like there may be an error in the conf.json file. Can you post the content of that?
  3. micah1711

    micah1711 New Member

    Messages:
    3
    Likes Received:
    0
    Sorry about the delay.

    Here are the contents of the control.json file:

    var fs = require('fs');
    var conf = JSON.parse(fs.readFileSync(__dirname + "/conf.json", {encoding: "ascii"}));

    var paVersion = fs.readFileSync(conf.serverversion, {encoding: "ascii"}).trim();

    console.log("PA version is "+paVersion);

    var serverExe = conf.server;
    var params = conf.serverparams;
    var paStatsHost = conf.pastats;
    var paStatsPort = conf.pastatsport;

    var serverIp = conf.serverip;
    var serverPort = conf.serverport;

    var paserver = require('./pa.js').paserver;

    var sendGameToPaStats = function(game) {
    var http = require('http');

    var payload = JSON.stringify(game);

    payload = payload.replace(/([\x09\x0A\x0D\x20-\x7E]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x$

    console.log("payload send to PA Stats:");
    console.log("____");
    console.log(payload);
    console.log("____");

    var headers = {
    'Content-Type': 'application/json; charset=utf-8',
    'Content-Length': payload.length
    };

    var options = {
    host: paStatsHost,
    port: paStatsPort,
    path: '/addServer',
    method: 'POST',
    headers: headers
    };

    // Setup the request. The options parameter is
    // the object we defined above.
    var req = http.request(options, function(res) {
    res.setEncoding('utf-8');

    var responseString = '';

    res.on('data', function(data) {
    responseString += data;
    });

    res.on('end', function() {

    });
    });

    req.on('error', function(e) {
    console.log("error while sending game to pa stats");
    console.log(e);
    });

    req.write(payload);
    req.end();
    };

    var lobbyId = (Math.random() * 99999999999999).toFixed(0);

    paserver.registerListener(function(beacon) {
    var p = JSON.parse(beacon);
    p.region = conf.shownregion;

    var payload = {
    beacon: JSON.stringify(p),
    ip: serverIp,
    port: serverPort,
    id: lobbyId,
    version: paVersion
    };

    if (conf.listonpastats) {
    sendGameToPaStats(payload);
    }
    });

    paserver.setServerDiedListener(function() {
    lobbyId = (Math.random() * 999999999999999).toFixed(0);
    setTimeout(function() {
    paserver.init(serverExe, params);
    }, 3000);
    });

    paserver.init(serverExe, params);
  4. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,327
    Likes Received:
    2,125
    "conf.json", not "control.js". Close! ;)
  5. micah1711

    micah1711 New Member

    Messages:
    3
    Likes Received:
    0
    Are you saying I should run conf.json instead of control.json?

    Because when I run conf.json I get similar errors.

    Im sorry to be so helpless.
  6. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,327
    Likes Received:
    2,125
    No, I meant you should post the content of conf.json. The conf.json file is read by the control.js file in this line:
    Code:
    var conf = JSON.parse(fs.readFileSync(__dirname + "/conf.json", {encoding: "ascii"}));
    The error you posted earlier seems to suggest that there may be a formatting error in the conf.json file.

Share This Page