Skip to content

How to set up a test server (only a few features are working)

MathieuB8 edited this page Nov 10, 2017 · 2 revisions
  • Connecting to the test server : ✔️
  • Irc : ✔️
  • Hosting & joining game : ❌ /✔️ (not really working, I replaced all the links to faforever.com by the test server one, but unfortunately not working with it, but if instead you let content.faforever.com then it will work...)
  • Leaderboard : ❌
  • Vault : ❌
  • Unit db : ❓
  • Rating : ❓
  • Replay : ❓
  • Coop mission : ❓

LAST info :

Unfortunately I'm stucked on fixing the hosting & joining game (got a timeout when it is trying to get the files and I haven't found a solution), I also replaced in all the files faforever.com (client & server side) by the vps one.

Server side

Install docker
Clone the server repository
Clone the faf-stack repository
In the server repository, do :
cp faf-server.example.pem faf-server.pem

Go to the docker-compose.yml file in faf-stack folder (cd faf-stack), in the faf-python-server, edit the build to where you cloned the server repository, for example :
build: ../server
If the faf-python-server container is running :
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker-compose build faf-python-server

Then start the containers:
docker-compose up -d faf-statsd-exporter
docker-compose up -d faf-python-server
docker-compose up -d faf-unrealircd

You can see logs by doing for example :
docker logs --timestamps faf-python-server

It is also advised to dump an old db to your db (not sure about this part /!):
Download the dump.sql https://github.com/FAForever/faf-db-dump
docker exec -ti faf-db wget https://raw.githubusercontent.com/FAForever/faf-db-dump/master/dump.sql
then connect to your db :
docker exec -ti faf-db mysql -uroot -pbanana
then
source WhereverItIs/dump.sql

You can if you wish, edit the password/login for the db instead of using banana as a password.

If you have trouble connecting, maybe you need to open add these in iptables (I don't know if it is really necessary or not, and if you need all these ports or some are useless, just looked in the ports used in the source code) :
iptables -A INPUT -p tcp --match multiport --dports 7,53,67,80,123,194,547,587,3478,3306,3535,6112,30351,4112,6697,6666,6665,8067,7070,8167,9001 -j ACCEPT
iptables -A INPUT -p tcp --match multiport --dports 80,443,9125,194,3535,8000,6112,4112,30351,8001,11002,6665 -j ACCEPT iptables -A INPUT -p tcp --match multiport --dports 6666,6667,6697,9102,9104,9105,9125,15000,8099,5000,8098 -j ACCEPT iptables -A INPUT -p tcp --match multiport --dports 8092,3000,8090,8030,8020,8093,9090,8091,3535 -j ACCEPT (some ports are present 2 times but it shouldn't matter)

#endtime not present in db : You have to have the latest version, you can check what version you have in the table schema_version docker exec -ti faf-db ./migrate.sh

Commons errors & their solutions

Error in the log of faf-python-server container about statsd

You forgot to start the statsd container.
docker-compose up -d faf-statsd-exporter

Error in the log of faf-python-server container about some tables

You have to manually create them, so first connect to your db, for example :
docker exec -ti faf-db mysql -uroot -pbanana
then you have to create the tables missing.
"Table 'faf.updates_equilibrium_files' doesn't exist"
create table updates_equilibrium_files like updates_nomads_files;
"Table 'faf.updates_fafdevelop_files' doesn't exist":
create table updates_fafdevelop_files like updates_faf_files;
"Table faf.updates_fafdevelop doesn't exist"
create table updates_fafdevelop like updates_faf;
"Table 'faf.updates_equilibrium' doesn't exist"
create table updates_equilibrium like updates_nomads;

(TODO)

Error in the log of faf-python-server container about private key

There is probably a less dirty solution but you can edit the file config.py located in server folder and edit it :
AES_KEY_BASE64_SIZES = []
PRIVATE_KEY_BLOBS = os.getenv("FAF_PRIVATE_KEY", '').split(';')
PRIVATE_KEY_BLOBS = 'MIICWwIBAAKBgQCtkJA/oWgacOXpdsFMoO9nMh4mKJDR9dHDRbEOt0+AivOUoNP5yPiOgpCcJ6eV15nTMintjAFNqeBvYySrhFP1dLoI0jB65iA031V3qS7ls7oSQSgqgbsB9EHfN7/qJqSBF00a2ZHBA7dGak+n89DITqhnPNH/iwkXDaz2B0LOFQIBJQKBgDz7cPPDFr0ulfgU987QwtE7H1mD39sRLgZWwas5fMxMfxiLiL+LzPPNAmBg9bEwE3O3rd3XPrpsHmxTRDxDQBdkdFiMttRe6gCAOvCx339Ej6UkO1kIk1fi09XCtFuB8YvyhKe5WJxUDC6BzpduRhyv0h/AozjNzZaAFu2phsUtAkEA0/Pa2gFbjNksVYyevqhb4roG5oQ3ue81IsV82uMmyutaSX+SMzTjOMMwvVTDj47zbvgGIwnsqmsSJDWd0Pk3tQJBANGibQU6dCPAuFfmBHoeH5e1+kJJzf4ocDg1KVoWg9YxDqVnq0gR5cgMfZ39q4zcvk28y6a8cTRok6RJx3sseOECQQCr2noYi3qpjX3kf9qobNThWI/5LO7pyN75mTTNJuEu6FcLKSputUKcufAqzxsac+f5HCCmycbPXbuuqANrKu7lAkEAglA17n5IMeaAbf2vwYhY0+2pZ3n8lxI365arAKY2RuA5iWn02cXvs7S8yf6NO+MqMFLDyIL6QyxAGgRZaD49TQJAZKlAONqb8lP/4UTfYn/EPDtApBJrTOGyWUmT31U0x/r2UCSU6XClk8fxYrSDO4WNheYL0iQh89J6tiAaV2SqVQ=='
PRIVATE_KEY_BLOBS = PRIVATE_KEY_BLOBS.split(';')

Restarting forever for faforever/faf-unrealircd (the irc chat, no irc chat up when you connect to the server)

You can see the logs by doing :
docker logs --timestamps faf-unrealircd
First you have to find a file, do this :
find / | grep "run_anope.sh"
Then edit all run_anope.sh files and edit "hile true" to "while true"
docker stop faf-unrealircd
docker rm faf-unrealircd
docker-compose build faf-unrealircd
docker-compose up faf-unrealircd

Issue with the UID

The private key you added in the config.py file is not linked to the public key used by the uid executable, so you need to edit the db about your account you are using to connect to the test server :
Connect to the db :
docker exec -ti faf-db mysql -uroot -pbanana
Then edit the table login for your account, for example mine is called 'test' and has 'test_password' as password :
use faf;
select * from login where login='test';
UPDATE login set steamid=1 where login='test';

How to make an account to connect on this server

For example these ones : you will login with test/test_password or postman/postman docker exec -ti faf-db mysql -uroot -pbanana
use faf;
insert into login (steamid, login, email, password) values ('1', 'test', 'test@example.com', SHA2('test_password', 256));
insert into login (steamid, login, email, password) values ('2', 'postman', 'postman@example.com', SHA2('postman', 256));

Cannot host & join a game or same for ladder (the client is stucked on updating faf forever"

No good solution found yet
(working solution but it uses content.faforever.com (from the prod server) instead of your own one)
docker-compose up faf-legacy-server
docker exec -ti faf-legacy-updater mkdir -p ../content/faf/updaterNew/updates_faf_files/
docker exec -ti faf-legacy-updater wget content.faforever.com/faf/updaterNew/updates_faf_files/meshes.3677.nxt -P ../content/faf/updaterNew/updates_faf_files/
docker exec -ti faf-legacy-updater wget content.faforever.com/faf/updaterNew/updates_faf_files/lua.3677.nxt -P ../content/faf/updaterNew/updates_faf_files/
docker exec -ti faf-legacy-updater wget content.faforever.com/faf/updaterNew/updates_faf_files/loc.3677.nxt -P ../content/faf/updaterNew/updates_faf_files/
docker exec -ti faf-legacy-updater wget content.faforever.com/faf/updaterNew/updates_faf_files/projectiles.3677.nxt -P ../content/faf/updaterNew/updates_faf_files/
docker exec -ti faf-legacy-updater wget content.faforever.com/faf/updaterNew/updates_faf_files/ForgedAlliance.3677.exe -P ../content/faf/updaterNew/updates_faf_files/
docker exec -ti faf-legacy-updater wget content.faforever.com/faf/updaterNew/updates_faf_files/env.3677.nxt -P ../content/faf/updaterNew/updates_faf_files/
docker exec -ti faf-legacy-updater wget content.faforever.com/faf/updaterNew/updates_faf_files/en.3677.nxt -P ../content/faf/updaterNew/updates_faf_files/
docker exec -ti faf-legacy-updater wget content.faforever.com/faf/updaterNew/updates_faf_files/textures.3677.nxt -P ../content/faf/updaterNew/updates_faf_files/
docker exec -ti faf-legacy-updater wget content.faforever.com/faf/updaterNew/updates_faf_files/etc.3677.nxt -P ../content/faf/updaterNew/updates_faf_files/
docker exec -ti faf-legacy-updater wget content.faforever.com/faf/updaterNew/updates_faf_files/schook.3677.nxt -P ../content/faf/updaterNew/updates_faf_files/
docker exec -ti faf-legacy-updater wget content.faforever.com/faf/updaterNew/updates_faf_files/units.3677.nxt -P ../content/faf/updaterNew/updates_faf_files/
docker exec -ti faf-legacy-updater wget content.faforever.com/faf/updaterNew/updates_faf_files/effects.3677.nxt -P ../content/faf/updaterNew/updates_faf_files/
docker exec -ti faf-legacy-updater wget content.faforever.com/faf/updaterNew/updates_faf_files/modules.3677.nxt -P ../content/faf/updaterNew/updates_faf_files/

Then edit these files :
faf-stack/config.template/faf-legacy-updater/updater.conf
faf-stack/config/faf-legacy-updater/updater.conf
And replace 'localhost' by 'content.faforever.com'
docker stop faf-legacy-updater
docker rm faf-legacy-updater
docker-compose build faf-legacy-updater
docker-compose up -d faf-legacy-updater
So right now it won't download the files located locally on the server but download them from content.faforever.com (half working solution).

The update is chosen based on the 'updates_faf_files' if you want to play a normal game, it will take the latest version and download the files associated with it. So you need to have the files on your server (like I showed with with wget for faf-legacy-updater) but also update this table.

Check version issue

There is probably a better solution but right now in the "server/lobbyconnection.py" file, edit the method like this: def check_version(self, message):
return True

Db is not wiped even after rmi/rm/volume cleaning

You need to delete the folder "data" in the faf-stack too.

Avoid downloading different version between production & test server

You have the latest files in order to avoid downloading every time different versions :
WIP
docker exec -ti faf-legacy-updater mkdir -p ../content/faf/updaterNew/updates_faf_files/
docker exec -ti faf-db mysql -uroot -pbanana
use faf;
INSERT INTO updates_faf_files VALUES (1075,22,3689,'etc.3689.nx2','7ccc8eaa854055880d07daaeb045dc1e',0),(1076,12,3689,'env.3689.nx2','6ffd025727d9ffd871e2198ea0385aa7',0),(1077,11,3689,'effects.3689.nx2','6ffb3793a3a5ee00539bb647776ec84f',0),(1078,21,3689,'units.3689.nx2','4f2ffefdbe2320eed9df61faca14e712',0),(1079,15,3689,'meshes.3689.nx2','bd5873107c2f79b965d097e4ca542a18',0),(1080,18,3689,'projectiles.3689.nx2','d6e1ec5f613146ea8caa876d211078d6',0),(1081,19,3689,'schook.3689.nx2','75aa37b5a77d314acf5ad51a59c89eaa',0),(1082,14,3689,'lua.3689.nx2','98d184cb15df5647822ff5f9ca99efa3',0),(1083,13,3689,'loc.3689.nx2','4cae8c7af067f2c2b2dedf7d30a5feb5',0),(1084,20,3689,'textures.3689.nx2','a24fe8fa73bbe50e1c25a522ab74470d',0),(1085,1,3689,'ForgedAlliance.3689.exe','6ca19563c80509050f7693cd19d1526e',0);

Once you updated the table you can now download the files by using this script
https://gist.github.com/MathieuB8/e3fed851452a3c9062d3e5d7c1724afb
or this one (original one which has been edited in the above link but it will download lot of differents things) :
https://gist.github.com/duk3luk3/f247be7844646929729bf2ed5d9d3dd7
Once you started the script, it will download the files in a folder, copy it to the container :
docker cp updates_faf_files/ faf-legacy-updater:/content/faf/updaterNew/

If you don't want to use the script, do this : docker exec -ti faf-legacy-updater wget http://content.faforever.com/faf/updaterNew/updates_faf_files/etc.3689.nx2 -P ../content/faf/updaterNew/updates_faf_files/ docker exec -ti faf-legacy-updater wget http://content.faforever.com/faf/updaterNew/updates_faf_files/env.3689.nx2 -P ../content/faf/updaterNew/updates_faf_files/ docker exec -ti faf-legacy-updater wget http://content.faforever.com/faf/updaterNew/updates_faf_files/effects.3689.nx2 -P ../content/faf/updaterNew/updates_faf_files/ docker exec -ti faf-legacy-updater wget http://content.faforever.com/faf/updaterNew/updates_faf_files/units.3689.nx2 -P ../content/faf/updaterNew/updates_faf_files/ docker exec -ti faf-legacy-updater wget http://content.faforever.com/faf/updaterNew/updates_faf_files/meshes.3689.nx2 -P ../content/faf/updaterNew/updates_faf_files/ docker exec -ti faf-legacy-updater wget http://content.faforever.com/faf/updaterNew/updates_faf_files/projectiles.3689.nx2 -P ../content/faf/updaterNew/updates_faf_files/ docker exec -ti faf-legacy-updater wget http://content.faforever.com/faf/updaterNew/updates_faf_files/schook.3689.nx2 -P ../content/faf/updaterNew/updates_faf_files/ docker exec -ti faf-legacy-updater wget http://content.faforever.com/faf/updaterNew/updates_faf_files/lua.3689.nx2 -P ../content/faf/updaterNew/updates_faf_files/ docker exec -ti faf-legacy-updater wget http://content.faforever.com/faf/updaterNew/updates_faf_files/loc.3689.nx2 -P ../content/faf/updaterNew/updates_faf_files/ docker exec -ti faf-legacy-updater wget http://content.faforever.com/faf/updaterNew/updates_faf_files/textures.3689.nx2 -P ../content/faf/updaterNew/updates_faf_files/ docker exec -ti faf-legacy-updater wget http://content.faforever.com/faf/updaterNew/updates_faf_files/ForgedAlliance.3689.exe -P ../content/faf/updaterNew/updates_faf_files/

Python client side

TODO
(not sure it is enough)
Edit %appdata%\Roaming\ForgedAllianceForever\FA Lobby.ini :
Add these lines at the end of files :
[lobby]
host=ipofyourtestserver
[chat]
host=ipofyourtestserver
The ipofyourtestserver can also be localhost, depends where the server is (on your machine or not).