Setup Rhisis on Debian 9

Topic created · 1 Posts · 95 Views
  • This guide will help you to set up a Rhisis server instance on a Debian 9 environment. We will first see how to install the dependencies and then we will install and configure a Rhisis instance.

    There is two ways of installing Rhisis. From the source code or from an official release.

    Install Rhisis from source-code

    In this section we will see how to install a Rhisis server using the latest sources and configure the server.


    Before you get started, you will need to install some packages on your Debian system.
    First of all, update all of you existing packages by typing the following commands:

    $> sudo apt-get update
    $> sudo apt-get upgrade

    The apt-get update command will download the list of packages from the Debian repositories, but will not install any package.
    The apt-get upgrade actually installs newer versions of the packages you have. After updating the lists, the package manager knows about available updates for the software you have installed.

    Now that our Debian environment seems up-to-date, let's install some packages to run Rhisis. We will need to install git to checkout the source code, dotnet to execute the Rhisis servers and mysql-server to store the server's data.

    $> sudo apt-get install git

    Once git is installed, you can now install .NET Core.
    You can find all the installation instructions here: .NET Core SDK install instructions

    .NET Core

    To install .NET Core SDK, type the following commands to register the Microsoft key, product repository and install all dependencies, type the following commands:

    $> wget -qO- | gpg --dearmor > microsoft.asc.gpg
    $> sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
    $> wget -q  
    $> sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list  
    $> sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg  
    $> sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list

    Now the product repository is set up, run an apt-get update to update the package list and then install dotnet-sdk

    $> sudo apt-get update
    $> sudo apt-get install dotnet-sdk-2.2

    ℹ️ if you are facing issues with the following error: E: The method driver /usr/lib/apt/methods/https could not be found., please install the apt-transport-https with the following command:

    $> sudo apt-get install apt-transport-https

    And then re-execute the sudo apt-get install dotnet-sdk-2.2 command.

    To make sure .NET Core is installed run the following command and you shall see the following output:

    $> dotnet --version

    MySQL Server

    ℹ️ *You can find the MySQL Server install instructions here: MySQL Server install

    First of all, we will need to download the repository from the MySQL official website and then install it:

    $> cd /tmp/
    $> wget

    Now that the repository is downloaded, we can install it using the dpkg command:

    $> sudo dpkg -i mysql-apt-config*

    During the installation, you'll be presented with a configuration screen where you can specify which version of MySQL you'd prefer, along with an option to install repositories for other MySQL-related tools. The defaults will add the repository information for the latest stable version of MySQL and nothing else. This is what we want, so use the down arrow to navigate to the Ok menu option and hit ENTER.

    MySQL repository is now installed on our Debian environment, we can now run a apt-get update to update the package list:

    $> sudo apt-get update

    Then, install the mysql-server package:

    $> sudo apt install mysql-server

    During installation, you will be asked to enter the root password, be sure to choose a strong password. Also, you can choose the Use Strong Password Encryption option.

    Once it is installed, check if the mysql server is running correcly:

    $> systemctl status mysql
    ● mariadb.service - MariaDB 10.1.37 database server
       Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
       Active: [active (running)] since Sun 2019-03-03 10:22:42 CET; 26s ago
         Docs: man:mysqld(8)
     Main PID: 22203 (mysqld)
       Status: "Taking your SQL requests now..."
       CGroup: /system.slice/mariadb.service
               └─22203 /usr/sbin/mysqld

    ℹ️ If the mysql-server didn't asked you for the root password, run the following command to secure your mysql server installation: mysql_secure_installation

    Download and build Rhisis

    Now that git and dotnet is installed, we will need to download the Rhisis source code and compile in order to run the servers.
    Create a folder wherever you want in your disk.

    :info: For this guide, I will use the /home/rhisis/ folder.

    Navigate to /home/rhisis/ and type the following commands to download the sources:

    $> cd /home/rhisis/
    $> git clone server

    The first cd command will Change Directory to the /home/rhisis folder.
    Then, the git clone ADDRESS server will download the sources into the server folder.

    Now again, go to the server directory with the cd command:

    $> cd server/

    If you type the command ls -la you can see the content of the current folder:

    $> ls -la
    total 100
    drwxr-xr-x  8 root root  4096 Mar  2 12:27 .
    drwxr-xr-x  3 root root  4096 Mar  2 12:27 ..
    drwxr-xr-x  4 root root  4096 Mar  2 12:27 bin
    -rw-r--r--  1 root root  1174 Mar  2 12:27
    -rw-r--r--  1 root root  3289 Mar  2 12:27
    drwxr-xr-x  3 root root  4096 Mar  2 12:27 docs
    drwxr-xr-x  8 root root  4096 Mar  2 12:27 .git
    -rw-r--r--  1 root root  2546 Mar  2 12:27 .gitattributes
    -rw-r--r--  1 root root  3760 Mar  2 12:27 .gitignore
    -rw-r--r--  1 root root 35141 Mar  2 12:27 LICENSE
    -rw-r--r--  1 root root  3815 Mar  2 12:27
    -rw-r--r--  1 root root  8014 Mar  2 12:27 Rhisis.sln
    drwxr-xr-x  4 root root  4096 Mar  2 12:27 script
    drwxr-xr-x 11 root root  4096 Mar  2 12:27 src
    drwxr-xr-x  4 root root  4096 Mar  2 12:27 test
    -rw-r--r--  1 root root   979 Mar  2 12:27 .travis.yml

    Alright, we now have the sources. Let's compile Rhisis in release mode using the dotnet build command:

    $> dotnet build --configuration Release

    .NET Core will install the solution's packages and build the entire solution.

    Server configuration

    To setup the Rhisis emulator, including the database, we are going to use the Rhisis CLI tool.
    Before running the tool, we are going to create a symbolic link to the Rhisis CLI binary, navigate to the bin/ folder and execute the following command:

    $> chmod +x ./rhisis-cli

    Now, our Rhisis CLI is ready to use. To setup the emulator and database type the following command:

    $> ./rhisis-cli setup

    The Rhisis CLI will prompt several fields you will need to specify in order to configure the login, cluster, world server and the database access.
    As for the database configuration, you will be asked which provider to use, simply choose MySQL. Then, enter your MySQL account and password (root, or any other one you have created), finally, choose a database name and continue the installation.

    ℹ️ The Rhisis CLI will create the configuration files for login, cluster, world and database, and save the configuration into the config folder.

    Create a test account

    To create an account on the server we have configured, you can use the Rhisis CLI user command:

    $> ./rhisis-cli user create

    This command will ask you for an username, password, password salt (use "kikugalanet"), and the authority (simple player, GM or admin).

    Server services

    In order to maintain the servers online and restart them if one of them crash, we will need to create 3 services using Debian systemd.

    More informations about Debian systemd here

    Navigate to folder /etc/systemd/system and create a new file named: rhisis-login and insert this content:

    Description=Rhisis Login Server
    ExecStart=/usr/bin/dotnet run --project /home/rhisis/server/src/Rhisis.Login/Rhisis.Login.csproj -c Release

    This script describes the behavior of the service. As you can see, this is the script for the Rhisis Login Server. It will start the server automatically after a system reboot and after the mysql.service started.
    In the [Service] section, we specify the WorkingDirectory and command to execute to start the service (ExecStart).
    We can also see that the server will restart 10 seconds after it crashed.

    As for the the Cluster and World Server, the script is nearly the same:


    Description=Rhisis Cluster Server
    ExecStart=/usr/bin/dotnet run --project /home/rhisis/server/src/Rhisis.Cluster/Rhisis.Cluster.csproj -c Release


    Description=Rhisis World Server
    ExecStart=/usr/bin/dotnet run --project /home/rhisis/server/src/Rhisis.World/Rhisis.World.csproj -c Release

    Once you created the 3 services files, reload the services using the command:

    $> sudo systemctl daemon-reload

    Starting the servers

    To start the servers, simply start the services we created previously:

    $> sudo systemctl start rhisis-login

    To make sure the server has started, type the following command:

    $> sudo systemctl status rhisis-login
    ● rhisis-login.service - Rhisis Login Server
       Loaded: loaded (/etc/systemd/system/rhisis-login.service; disabled; vendor preset: enabled)
       Active: [active (running)] since Sun 2019-03-03 16:07:31 CET; 14s ago
     Main PID: 26424 (dotnet)
        Tasks: 30 (limit: 4915)
       CGroup: /system.slice/rhisis-login.service
               ├─26424 /usr/bin/dotnet run --project /home/rhisis/server/src/Rhisis.Login/Rhisis.Login.csproj -c Release
               └─26464 dotnet exec /home/rhisis/server/src/Rhisis.Login/bin/Release/netcoreapp2.2/Rhisis.Login.dll

    You should always start the servers in this order:

    1. Login Server (rhisis-login.service)
    2. Cluster Server (rhisis-cluster.service)
    3. World Server (rhisis-world.service)