# Launch Diarkis Server on Windows Environment

## Introduction

You can also build and run the Diarkis server as a Windows binary.

This allows client engineers developing on a Windows machine to operate the Diarkis server without WSL, aiding in the efficiency of development work.

However, please note that it is not intended for use in production environments, so it should be limited to local or development environments.

## Operating Environment

As of 2025-04-04, the operation is assumed in the following environments:

* Windows 10/11
* Go 1.22 or later
* (git, if you're cloning the repository using git)

## Procedure

### Installing Required Tools

Install Go 1.22 or later. <https://go.dev/doc/install>

You can also install it using a package manager like scoop.

```powershell
> scoop install go
```

### Installing Diarkis Server Template

#### If Cloning the Repository

Clone <https://github.com/Diarkis/diarkis-server-template>.

<pre class="language-powershell"><code class="lang-powershell"><strong>> git clone git@github.com:Diarkis/diarkis-server-template.git
</strong># Check out the version tag you need, if necessary
> git checkout v1.1.0-beta1
</code></pre>

#### If Downloading Assets

Open <https://github.com/Diarkis/diarkis-server-template/releases>, download the latest version Assets, and extract and use them.

### Generating the Project

Run the following command in PowerShell to generate the project.

{% code overflow="wrap" %}

```powershell
# parameters: {project_id} {builder_token} {output} {module_name}
> .\run-mage.bat init 12345678901 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ../server_bin server_bin
```

{% endcode %}

* `project_id`: Project ID issued by our company
* `builder_token`: Builder Token issued by our company
* `output`: Output destination of the generated project. Here, it is explained as `../server_bin`
* `module_name`: Module name. Here, it is explained as `server_bin`

### Project Initialization

Move to the directory where the project was output and execute the following command.

```powershell
> cd ..\server_bin
> .\run-mage.bat init
```

### Build

Execute the following command to build the Diarkis server binary.

```powershell
> .\run-mage.bat build:local
```

Once the build is complete, the binary is output to the remote\_bin directory.

### Execution

Start mars, http, and udp each in separate PowerShell windows.

```powershell
> .\run-mage.bat server mars
> .\run-mage.bat server http
> .\run-mage.bat server udp
```

### Verification of Operation

You can verify communication using the Go test client.

```powershell
# parameters: <HTTP address> <client user ID> <client key> <puffer enabled: true/false>
> .\run-mage.bat goCli 127.0.0.1:7000 user-1 key false
```

* HTTP address: Address of the Diarkis HTTP server
* client user ID: ID of the user for authentication.
* client Key: Client key. Specify `key` in the development environment
* puffer enabled: Use of the Diarkis Puffer module. Specify false here

If authentication is successful, it will display as follows and enter the command waiting state.

```
[UID: user-1][SID(UDP): 23942c034d8d4094b09ab7219d28cebc]
 > Connected UDP
```

To create a Room after connection, you can create it by executing the following command.

```
 > Connected UDP
room create
Enter for which protocol to a create a Room (TCP/UDP): (Default: UDP)
Invalid input. Set to default value: UDP
Enter max members [1 - 255] (uint16): (Default: 10)
Invalid input. Set to default value: 10
Enter if allow empty (y/n): (Default: no)
Invalid input. Set to default value: false
Enter if join on creation (y/n): (Default: yes)
Invalid input. Set to default value: true
Enter TTL (seconds) [10 - 65535] (uint16): (Default: 30)
Invalid input. Set to default value: 30
Enter broadcast interval (milliseconds) (uint16): (Default: 100)
Invalid input. Set to default value: 100
# UDP RoomID is displayed on the prompt and you are in the state of joined Room
[UID: 1111][SID(UDP): c51ea8010bc44ea5b6cd6ef2bb788ad8][UDP RoomID: 580e3cef8588bd287f0000011fa5000000000000000000000000]
```

## Supplemental Information

### Test Client

In the test client, you can execute various built-in commands in addition to the `room create` command to verify. Please check the following page of the help center for details.

{% embed url="<https://help.diarkis.io/getting-started/tutorial/test-client>" %}

### `magefile`

`.¥run-mage.bat` uses a Go tool called [magefile](https://magefile.org/) internally.

Like make/rake, it is a build tool that allows build flows to be described in Go, enabling platform-independent management.

If you want to check other targets, you can do so by running it without any arguments as follows.

```
> .\run-mage.bat
Targets:
  build:linux              Build server binary for linux or container environment
  build:local              Build server binary for local use
  build:mac                Build server binary for mac use
  diarkis:changeVersion    Change diarkis version.
  diarkis:version          Print the version of diarkis currently used.
  goCli                    Starts Go test client.
  init                     Initialize project
  puffer:clean             Delete all generated protocol code files.
  puffer:gen               Generate go, cpp, and cs code files using puffer (Diarkis packet gen module) from packet definition written in json.
  server                   Start a server locally: Required 1 following argument: mars http udp tcp
```

#### fakesignal

Diarkis uses UNIX signals such as SIGUSR1 and SIGUSR2to provide functionalities like switching log levels and toggling debug features ON/OFF. However, signals like SIGUSR1 do not exist on Windows.

Therefore, we have included a tool called `fakesignal` in the diarkis-server-template, allowing testing to be conducted even on Windows.
