1. Launch Diarkis Server Locally

Introduction

This page explains the steps for launching the Diarkis server in your local environment using Diarkis Server Template. We recommend going through these steps before starting development with Diarkis.

Environment Setup

To introduce the server template, Go version 1.22 or later is required.

The installation method varies by platform, so please follow the official documentation for installation. https://go.dev/doc/install

Diarkis server development can be done on macOS, Linux, and Windows.

In Windows environments, operation is confirmed with WSL1 on Windows 10 (Ubuntu 20.04). Since WSL2 does not support UDP port forwarding, please use WSL1.

If you are not using WSL1, you can convert your WSL environment by starting PowerShell with administrative privileges and executing the command wsl --set-version Ubuntu-20.04 1.

Generating a Project from the Server Template

  1. First, clone the repository by executing git clone https://github.com/Diarkis/diarkis-server-template.git in any PATH.

  2. Execute the following command to generate the project. The output will be an absolute path specified as output.

make init project_id={project ID} builder_token={builder token} output={absolute path to install}

# Example
make init project_id=00000000000 builder_token=xxxx-yyyy-zzzz output=/tmp/diarkis-dir

The project ID and builder token specified here are credentials issued to developers with a Diarkis enterprise license. Since the core of Diarkis is built as a closed source and implemented in Go, it is necessary to use diarkis-cli to build.

If you need an older version, you can either check out a tag of the desired version or download it from the release list.

Setup

Execute the following command in the generated project.

cd path/to/project
make init

This will download various resources needed for development (e.g., references for using code completion).

Generating Server Binaries

To generate binaries for local use, execute the following make task.

make build-local

After executing the above, Diarkis binaries will be generated under remote_bin.

% ls remote_bin
health-check http         mars         ms           tcp          testcli      udp

Starting the Server

Start the MARS, HTTP, and UDP servers.

make server target=mars
make server target=http
make server target=udp
# Although not used in this tutorial, the TCP server can be started with the following command:
# make server target=tcp

# You can also start them with the following commands without using the make command
./remote_bin/mars ./configs/mars/main.json
./remote_bin/http
./remote_bin/udp

Retrieving Connection Information

If mars, http, and udp are running, you can retrieve connection information using curl as follows. This completes the server setup.

% curl -X POST http://127.0.0.1:7000/endpoint/type/UDP/user/test
{"encryptionMacKey":"xxxxxxxxxx","serverType":"UDP","serverHost":"127.0.0.1","serverPort":7100,"sid":"xxxxxxxxxx","encryptionKey":"xxxxxxxxxx","encryptionIV":"xxxxxxxxxx"}%

The above HTTP endpoint signifies that uid test has been authenticated against the UDP server. The information returned from here can be used by various client libraries to exchange packets.

Last updated