# Set Up Field Module on Server

## Overview <a href="#setting-diarkis-room" id="setting-diarkis-room"></a>

The Field module needs to be set up on HTTP, UDP, and TCP servers.

By managing Field's memory data through the HTTP server and exposing built-in commands via UDP and TCP servers, you can make them available for use.

## Setup <a href="#configuring-built-in-commands" id="configuring-built-in-commands"></a>

Add the following to the main function of the HTTP server.

```go
package main

import "github.com/Diarkis/diarkis/diarkisexec"

func main() {
	logConfigPath := "/configs/shared/log.json"
	meshConfigPath := "/configs/shared/mesh.json"

	diarkisexec.SetupDiarkis(logConfigPath, meshConfigPath, &diarkisexec.Modules{
		Field: &diarkisexec.Options{ConfigPath: "/configs/shared/field.json", ExposeCommands: true},
	})

	diarkisexec.SetupDiarkisHTTPServer("/configs/http/main.json")
	diarkisexec.StartDiarkis()
}
```

To expose built-in commands to clients, you can set it up using the diarkisexec package.

Similarly, add it to the main function of the UDP and TCP servers. Below is a sample setup for a UDP server. The setup function of diarkisexec must be executed before calling `diarkisexec.StartDiarkis()`.

For more details, please refer to the [API Reference for diarkisexec](https://docs.diarkis.io/docs/server/current/diarkis/diarkisexec/index.html).

```go
package main

import "github.com/Diarkis/diarkis/diarkisexec"

func main() {
	logConfigPath := "/configs/shared/log.json"
	meshConfigPath := ""

	diarkisexec.SetupDiarkis(logConfigPath, meshConfigPath, &diarkisexec.Modules{
		Field: &diarkisexec.Options{ConfigPath: "/configs/shared/field.json", ExposeCommands: true},
	})
	diarkisexec.SetupDiarkisUDPServer("/configs/udp/main.json")
	diarkisexec.StartDiarkis()
}
```

It is recommended to first use the server template to easily launch the server. [Diarkis Server Template](/en/getting-started/diarkis-server-template.md)


---

# 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/diarkis-modules/field/setup-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.
