1. Launch Diarkis Server in Local Environment

Introduction

This page provides a guide on how to start a Diarkis server in your local environment using the Diarkis Server Template. It is recommended to go through these steps before beginning development with Diarkis.

Environment Preparation

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

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

Server development with Diarkis can be performed on macOS, Linux, and Windows.

If you're starting the server in a Windows environment, please refer to Launch Diarkis Server on Windows Environment.

Generating a Project from the Server Template

  1. First, clone the repository by running git clone https://github.com/Diarkis/diarkis-server-template.git at a desired 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 issued to developers who have an enterprise license for Diarkis. The core of Diarkis itself is closed-source and implemented in Go, requiring you to build it using diarkis-cli.

If previous versions are needed, you can either check out the desired version’s tag or download it from the release list.

Setup

Run 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 code completion.

Generating Server Binaries

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

make build-local

Upon execution, Diarkis binaries will be created under remote_bin.

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

Starting the Server

Start each of 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 following commands can be used without the make command
./remote_bin/mars ./configs/mars/main.json
./remote_bin/http
./remote_bin/udp

Obtaining Connection Information

If mars, http, and udp are running, you can obtain 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 above HTTP endpoint indicates authentication to the UDP server with uid test. The returned information can then be used by various client libraries to facilitate packet exchange.

Last updated

Was this helpful?