[WIP] dedicated servers

Discussion in 'Work-In-Progress Mods' started by cola_colin, October 10, 2014.

  1. FSN1977

    FSN1977 Active Member

    Messages:
    657
    Likes Received:
    232
    This is the destination where I find Lobby.js "Planetary Annihilation\stable\media\server-script\states" it wont let me add more than 10 slots,
  2. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    and you set MAX_PLAYERS to a higher value?
    And you fixed ALL places with the 10 and 5 in the new_game.js UI file?
  3. ch1ll4x

    ch1ll4x New Member

    Messages:
    5
    Likes Received:
    2
    I've got the server up and running, but only one user can connect at a time. The second user can connect but gets kicked out almost immediately.

    [02:54:33.089] INFO 205.250.x.x:29076: connection established
    [02:54:33.093] INFO 205.250.x.x:29076: recvLogin()
    [02:54:33.093] INFO 205.250.x.x:29076: handleLogin()
    [02:54:33.093] INFO 205.250.x.x:29076: sending login acceptance
    [02:54:33.093] INFO sending sim created message
    [02:54:33.105] INFO New client: [censored] 2/2 clients connected
    [02:54:33.136] INFO 205.250.x.x:29076: close()
    [02:54:33.136] INFO [censored] disconnected. 1/2 clients remaining
    [02:54:33.279] INFO 205.250.x.x:29076: recvCmd()
    [02:54:33.652] INFO 205.250.x.x:29076: recvCmd()
    [02:54:33.652] INFO 205.250.x.x:29076: command channel closed
    [02:54:33.652] INFO 205.250.x.x:29076: reset()
    [02:54:44.158] INFO 205.250.x.x:29101: connection established
    [02:54:44.161] INFO 205.250.x.x:29101: recvLogin()
    [02:54:44.161] INFO 205.250.x.x:29101: handleLogin()
    [02:54:44.161] INFO 205.250.x.x:29101: sending login acceptance
    [02:54:44.161] INFO sending sim created message
    [02:54:44.175] INFO New client: [censored] 2/2 clients connected
    [02:54:44.176] INFO 205.250.x.x:29101: close()
    [02:54:44.176] INFO [censored] disconnected. 1/2 clients remaining
    [02:54:44.330] INFO 205.250.x.x:29101: recvCmd()
    [02:54:44.719] INFO 205.250.x.x:29101: recvCmd()
    [02:54:44.719] INFO 205.250.x.x:29101: command channel closed
    [02:54:44.719] INFO 205.250.x.x:29101: reset()

    Where have I gone wrong? Has anyone else had this issue?
  4. ch1ll4x

    ch1ll4x New Member

    Messages:
    5
    Likes Received:
    2
    Looks like this was an id-10-t error. I had the game set to private!
    proeleert and cola_colin like this.
  5. fuzzels

    fuzzels Member

    Messages:
    90
    Likes Received:
    34
    Should that not spell BEACON?

    What does it do? Seems to just print that string to the log every 5000 / 5seconds, if that string is set that is... but unless that ends up elsewhere too it will just fill the log, hence why add it?


    Seems that you are catching that string in pa.js before transmitting, hence I assume that BACON is so that you can catch that piggy from the logs and then transmit the status to the pastats server... alrighty.
  6. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    BACON is so much more tasty as one can read in the code of NodePAMaster:

    Code:
            var getTastyPart = function(str) {
                var myRe = /<BACON>(.*)<\/BACON>/;
                var parsed = myRe.exec(str);
                if (parsed && parsed.length === 2) {
                    return parsed[1];
                } else {
                    return undefined;
                }
            };
         
            keylogger.stdout.on("data", function(buffer) {
                var bufferString = buffer.toString();
                var tasty = getTastyPart(bufferString);
                if (tasty) {
                    for (var i = 0; i < listeners.length; i++) {
                        listeners[i](tasty); // this results in nodejs doing a POST to pastats.com
                    }
                } else {
                    console.log(bufferString);
                }
            });
    
    keylogger is the name of the pa server process in NodePAMaster, as I copied that code from another project I have where it is a keylogger.

    So basically I use console.log from inside the pa server code to communicate with the outside world.
  7. fuzzels

    fuzzels Member

    Messages:
    90
    Likes Received:
    34
    Yep, and it seems to work. Published in the pa-stats list.

    It is running fine on my E3-1240v3 @ 3.4Ghz in a KVM with only 8 GiB of mem allocated to it; no idea how many folks can join it though till it will fall apart, 5 AI and one real player on 8 planets seem to only take 4 GiB virtual upto now; something to test at one point or another. I'll let it run (currently has 3 spec slots available), and if the game end, it should allow new players to join and use it.
    proeleert and cola_colin like this.
  8. fuzzels

    fuzzels Member

    Messages:
    90
    Likes Received:
    34
    Hmmm is there a way to per default set the slots to the maximum? Now it per defaults shows "1" max slot, while it is actually a few more. Note that this likely comes out of the max_players in the JSON; where the system sets max_players to the slots configured, not to the maximum amount of slots; hence maybe just a misnomer.
  9. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    One could figure out what the "add slot" call does and maybe modify the server to call it X times when initializing.
  10. fuzzels

    fuzzels Member

    Messages:
    90
    Likes Received:
    34
    That is an idea, I'll dig in to that. I am actually a bit surprised to see those portions being in javascript and very editable; then again, makes sense as that allows modding quite well, which is a great thing :)

    In the mean time, this is the 'notes' I took for installing it. Requires Debian Unstable due to gocode being 1.0 in 'stable'/wheezy.

    This also adds a very simple init script that uses screen to start the server in. Thus everytime your box reboots it will properly be up and running again ;)

    Don't forget to replace YOURIP with an IPv4 address and YOURDESC with a description/server-name.

    Code:
    apt-get install mercurial gocode libgl1-mesa-glx unzip nodejs screen vim
    groupadd -g 1001 pa
    useradd -g pa -u 1001 pa
    su - pa
    # As 'pa' user
    hg clone https://bitbucket.org/papatcher/papatcher
    cd papatcher
    go run papatcher.go
    # This will 'fail' starting, because we got no video inside a KVM ;)
    cd ~/
    wget http://nanodesu.info/stuff/pa/mods/NodePAMaster.zip
    unzip NodePAMaster.zip
    cd ~/NodePAMaster/src/
    cat >conf.json <<HERE
    {
            "server": "/home/pa/.local/Uber Entertainment/Planetary Annihilation/stable/server",
            "serverversion": "/home/pa/.local/Uber Entertainment/Planetary Annihilation/stable/version.txt",
            "serverparams": ["--headless", "--game-mode", "Config", "--allow-lan","--server-name", "YOURDESC"],
            "pastats": "176.31.115.99",
            "pastatsport": 80,
            "listonpastats": true,
            "serverip": "YOURIP",
            "serverport": "6543",
            "shownregion": "pastats.com"
    }
    HERE
    
    # add:
    ------------
    setInterval(function() {
        if (server.beacon) {
            console.log("<BACON>"+JSON.stringify(server.beacon)+"</BACON>");
        }
    }, 5000);
    ------------
    # just after the first block of vars in:
    vi "/home/pa/.local/Uber Entertainment/Planetary Annihilation/stable/media/server-script/states/lobby.js"
    
    # Manual start:
    #cd ~/NodePAMaster/src
    #nodejs control.js
    
    cat >/home/pa/start.sh <<HERE
    #!/bin/bash
    
    cd ~/NodePAMaster/src
    nodejs control.js
    HERE
    chmod +x /home/pa/start.sh
    
    cat >/etc/init.d/pa <<HERE
    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides:          planetary-annihilation-server
    # Required-Start:    $remote_fs $syslog
    # Required-Stop:
    # Should-Start:
    # Default-Start:     2 3 4 5
    # Default-Stop:
    # Short-Description: Planetary Annihilation Server
    # Description:       Controller for the Planetary Annihilation Server
    ### END INIT INFO
    
    PATH=/sbin:/usr/sbin:/bin:/usr/bin
    . /lib/init/vars.sh
    
    do_start () {
            su -l -s /bin/sh -c 'exec "$0" "$@"' pa -- screen -dmS pa /home/pa/start.sh
    }
    
    case "$1" in
      start|"")
            do_start
            ;;
      restart|reload|force-reload)
            echo "Error: argument '$1' not supported" >&2
            exit 3
            ;;
      stop)
            # No-op
            ;;
      *)
            echo "Usage: pa [start|stop|status]" >&2
            exit 3
            ;;
    esac
    HERE
    chmod +x /etc/init.d/pa
    update-rc.d pa defaults
    
    proeleert and cola_colin like this.
  11. Chemdude8

    Chemdude8 New Member

    Messages:
    25
    Likes Received:
    8
    Finally figured out my issue (kinda) when I was connecting to the 2 instance I would connect to the one I saw from PAStats but I should have simply connected to the 'Local' one instead (since I'm hosting it on the same box I am looking to play on). Weird that it apparently doesn't resolve its own ip, but iunno and seems to work by simply joining the game (I see the updates on the paStats text page so I know others would be able to see me/join me) -- Guess I need to make sure others are able to connect to my game, but I guess that will come.

    Edit - Had someone join so seems legit.
    Last edited: October 15, 2014
  12. fuzzels

    fuzzels Member

    Messages:
    90
    Likes Received:
    34
  13. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Can you show me such a beacon?
    Maybe somebody with a very special name joined the game and the unicode filter I put in fails.
  14. fuzzels

    fuzzels Member

    Messages:
    90
    Likes Received:
    34
    No players at the moment, and no funny unicode either.

    tcpdumping showed that nothing was being sent though; restarting the thing solved it.
  15. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Hmm maybe something got borked in the way nodejs interacted with the log of the server.
  16. Quitch

    Quitch Post Master General

    Messages:
    5,885
    Likes Received:
    6,045
    Not sure where I've gone wrong, but I cannot seem to get the server to listen.

    "server": "/home/quitch/.local/Uber Entertainment/Planetary Annihilation/stable/server",
    "serverversion": "/home/quitch/.local/Uber Entertainment/Planetary Annihilation/stable/version.txt",

    I've confirmed the paths above are correct, and running nodejs control.js gets everything running

    PA version is 73939
    [13:30:25.925] INFO Setting STEAM_RUNTIME to /home/quitch/.local/Uber Entertainment/Planetary Annihilation/stable/steam-runtime
    [13:30:25.925] INFO SDL: Built w/ v2.0.3, linked w/ v2.0.3
    [13:30:25.926] INFO Loaded buildID 2014101573939
    [13:30:25.926] WARN Crash reporting disabled.
    [13:30:25.926] INFO Starting background thread pool with 14 threads

    [13:30:25.928] INFO GameServerImpl::resetModUpdateAuthToken: Auth token reset to "ecd5645a-70da-4f2e-82a8-112762f04916"

    payload send to PA Stats:
    ____
    {"beacon":"{\"game_name\":\"eXoduseSportsTest\",\"whitelist\":[],\"require_password\":false,\"full\":false,\"max_players\":1,\"started\":false,\"game\":{},\"spectator_names\":[],\"blacklist\":[],\"max_spectators\":0,\"tag\":\"\",\"mod_names\":[],\"players\":0,\"cheat_config\":{\"cheat_flags\":{\"any_enabled\":false,\"allow_mod_data_updates\":false,\"allow_create_unit\":false,\"allow_change_control\":false,\"allow_change_vision\":false}},\"spectators\":0,\"player_names\":[],\"region\":\"pastats.com\"}","ip":"191.233.66.146","port":"6543","id":"68592085759155","version":"73939"}

    But when I run a netstat -a there's no evidence of anything listening on that port. I'm lost as to where I've gone wrong. The server shows up on the in-game lobby, but of course connections just timeout because the server isn't really there (or rather isn't connectable).

    This is all on Ubuntu 14.04 LTS.
  17. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    How do the server start params look like?
  18. Quitch

    Quitch Post Master General

    Messages:
    5,885
    Likes Received:
    6,045
    I'm assuming you mean the ones in conf.json. Let me know if I'm mistaken.

    {
    "server": "/home/quitch/.local/Uber Entertainment/Planetary Annihilation/stable/server",
    "serverversion": "/home/quitch/.local/Uber Entertainment/Planetary Annihilation/stable/version.txt",
    "serverparams": ["--headless", "--game-mode", "Config", "--allow-lan","--server-name", "eXoduseSportsTest"],
    "pastats": "176.31.115.99",
    "pastatsport": 80,
    "listonpastats": true,
    "serverip": "191.233.76.231",
    "serverport": "6543",
    "shownregion": "pastats.com"
    }

    Also confirmed that server is a running process on the VM after I kick off nodejs.
  19. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    First off the port changed in the most recent build, either use --port 6543 or figure out what port they use now.
    Then I'd first try to start ./server with all those params by hand and use netstat -tulpn to check if it is listening on the given port.
  20. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,328
    Likes Received:
    2,125
    It's 20545 nowadays.

Share This Page