# 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](/en/getting-started/diarkis-server-template.md). 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](/en/diarkis-server/setup-windows.md).

## 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`.

{% code overflow="wrap" %}

```bash
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
```

{% endcode %}

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](https://github.com/Diarkis/diarkis-server-template/releases).

## Setup

Run the following command in the generated project.

```bash
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.

```bash
make build-local
```

Upon execution, Diarkis binaries will be created under `remote_bin`.

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

## Starting the Server

Start each of the MARS, HTTP, and UDP servers.

```bash
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.

{% code overflow="wrap" %}

```bash
% 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"}%
```

{% endcode %}

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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.diarkis.io/en/getting-started/tutorial/setup-local-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
