-
Notifications
You must be signed in to change notification settings - Fork 2
Setup of a Session Server
We recommend to run the session server on the same machine as a simulation server, as it is very lightweight. See the hardware requirements of a simulation server here. However it may also run on an independent machine if you prefer. In that case, there is no special hardware requirements for a session server: it doesn't require any specific graphics card, nor a powerful CPU.
It is recommended to configure the BIOS of the computer for automatic reboot after power outage. This can be done by entering the BIOS at boot time and selecting:
- Power Management Setup → Restore AC Power Loss → Power on, or
- POWER → APM Configuration → Restore on AC Power Loss: [Power On], or
- something similar depending on your BIOS.
It is necessary that a session server be available from the Internet, so that it can be used by anyone.
So, the machine running the session server should be attached to a fully qualified domain name such as cyberbotics1.epfl.ch
for example.
The local router or firewall should allow inbound connections to this machine on port 443 (HTTPS).
You should also have a SMTP mail server allowing you to send mails from a script (see details below). This mail server may run on the local computer or externally through a local provider. The setup of a mail server is not covered by this guide.
Instructions are provided here for Ubuntu 20.04, however it may work on any other version of Linux. It is assumed that you will be running a simulation server on the same machine. If not, you can install the server edition of Ubuntu and skip step 2.
- Install Ubuntu 20.04:
- Choose the desktop version of Ubuntu 20.04. Simulation servers needs a X display and 3D OpenGL hardware acceleration which is easier to setup from a desktop version.
- Create a user account named
cyberbotics
(or anything else).
- Makes that this user account has the auto-login feature enabled, so that when you boot the machine it get automatically logged in.
- Configure the unattended upgrades to reboot after security updates.
- For your convenience, it is recommended to install ssh:
apt install ssh
. - Install apache2:
apt install apache2
. - Install a Let's Encrypt SSL certificate and choose to redirect HTTP traffic to HTTPS:
sudo apt install certbot python3-certbot-apache
-
sudo certbot --apache
(choose to redirect HTTP traffic to HTTPS)
- Install Python dependencies:
sudo apt-get install python3-pip python-is-python3
pip install tornado
-
Add rewrite rules to redirect traffic to simulation servers and Webots, including WebSocket:
sudo a2enmod proxy proxy_http proxy_wstunnel
- Edit
/etc/apache2/site-available/000-default-le-ssl.conf
and add the following lines at the end of theVirtualHost
section:RewriteEngine on # port redirection rules (for session_server.py, simulation_server.py and webots) # websockets (should come first) RewriteCond %{HTTP:Upgrade} websocket [NC] RewriteCond %{HTTP:Connection} upgrade [NC] RewriteRule ^/(\d*)/(.*)$ "ws://localhost:$1/$2" [P,L] # http traffic (should come after websocket) RewriteRule ^/load$ "http://localhost:1999/load" [P,L] RewriteRule ^/monitor$ "http://localhost:1999/monitor" [P,L] RewriteRule ^/session$ "http://localhost:1999/session" [P,L] RewriteRule ^/(\d*)/(.*)$ "http://localhost:$1/$2" [P,L]
-
Install the session server:
mkdir ~/session_server.py cd ~/session_server wget https://raw.githubusercontent.com/cyberbotics/webots/develop/resources/web/server/session_server.py
-
Configure the session server:
- Edit this file:
~/session_server/session.json
so that it contains the following (to be adapted to your local setup):
{ "port": 1999, "portRewrite": true, "server": "cyberbotics1.epfl.ch", "administrator": "admin@cyberbotics.com", "mailServer": "mail.infomaniak.com", "mailServerPort": 587, "mailSender": "support@cyberbotics.com", "mailSenderPassword": "********", "simulationServers": [ "cyberbotics1.epfl.ch/2000" ] }
- Edit this file:
-
Setup the automatic launch of the session server on reboot.
cd ~/.config mkdir -p autostart cd autostart echo "[Desktop Entry]" > session_server.desktop echo "Name=session_server" >> session_server.desktop echo "Exec=python /home/cyberbotics/session_server/session_server.py /home/cyberbotics/session_server/session.json" >> session_server.desktop echo "Type=Application" >> session_server.desktop echo "X-GNOME-Autostart-enabled=true" >> session_server.desktop
-
Reboot your server:
sudo reboot
To test the status of your session server, simply visit this URL: https://cyberbotics1.epfl.ch/monitor (replace cyberbotics1.epfl.ch
with the host name of your local setup).
And check the inbox of the administrator as it may have received a new message.
Now you can setup a simulation server on the same machine and other machines.