Launching Diarkis Server in a Local Environment

Introduction

This page explains the steps to start the Diarkis server locally using the Diarkis Server Template. It is recommended to go through these steps before starting development with Diarkis.

Environment Preparation

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

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

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

In a Windows environment, operations are confirmed on 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 the WSL environment by starting PowerShell as an administrator and running the command wsl --set-version Ubuntu-20.04 1.

Generate 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 destination will be the absolute path specified in 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 mentioned here are information issued to developers with an enterprise license of Diarkis. Since the Diarkis main body itself is created as closed-source and implemented in Go, it needs to be built using diarkis-cli.

If you need a past version, you can use it by checking out a tag of any version or downloading 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 necessary for development (such as references for using code completion).

Generating the Server Binary

To generate binaries for local use, run the following make task:

make build-local

When you run the above, the Diarkis binaries will be generated under remote_bin.

% ls remote_bin
health-check http         mars         ms           tcp          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

# Alternatively, the servers can also be started with the following commands
./remote_bin/mars ./configs/mars/main.json
./remote_bin/http
./remote_bin/udp

Getting Connection Information

If mars, http, and udp are started, you can obtain the connection information with curl as follows. This completes the server startup.

% 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 HTTP endpoint above means that it has authenticated with the UDP server with uid test. The information returned from this can be used by various client libraries to exchange packets.

Last updated