# FiveDash Agent

Install the agent on the server's machine to start, stop, restart and watch FXServer from the panel, without txAdmin and without opening ports.

Source: https://fivedash.fivex.gg/docs/en/server/agent

The **FiveDash Agent** is a Windows service that lives on the FiveM server's machine. It starts FXServer, reads the console, restarts the city if it crashes or hangs, downloads artifacts from Cfx.re and edits `server.cfg`, all at the panel's request. It's what makes the **Console**, **Resources** and **Deploy** pages of the **Server** module work.

## Before you start

* **Where:** **Server → Agent**.
* **Access level:** **Agent** area, **Configure** level, to install, replace or remove it. With **View**, you only see whether it's connected.
* **Machine:** 64-bit Windows (VPS or dedicated) with FXServer. You need to open PowerShell as administrator.
* **Server folder:** know where the folder with `server.cfg` is (for example, `C:\FXServer\server-data`).

> The agent connects to FiveDash, not the other way around. The machine doesn't need to open any new port besides the game's (30120).

## Install

### Close the server

If the city is open through `server.bat` or txAdmin, close it first. After installing, the agent is what starts FXServer.

### Open PowerShell as administrator

On the server's machine, right-click **Windows PowerShell** and choose **Run as administrator**.

### Enter the server folder

In **Server → Agent**, type the full path of the folder that has `server.cfg`.

### Generate the command and run it

Click **Generate command**, copy the line and paste it into PowerShell. The command downloads the agent from FiveDash, checks the file, installs the **FiveDash Agent** service and connects it to this server.

### Wait for the panel to show Connected

The page goes from **Waiting for the agent to connect…** to **Connected** by itself. Open **Server → Console** and click **Start**.

The command works **once** and for **30 minutes**. Don't send it to anyone: whoever runs it connects a machine to this server on FiveDash. If it expires, click **Generate another command**.

If the server folder already has FXServer (for example in `artifacts\FXServer.exe`, as in the usual `server.bat`), the agent uses that one until you pick an artifact in **Server → Resources → Artifacts**.

## What the agent does

| What                            | How                                                                                                                                                                                                             |
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Start, stop and restart         | When asked on the **Console**, and at the times in **Resources → Restarts**                                                                                                                                     |
| Come back after a crash or hang | Starts it again by itself, waiting a bit longer each try. It also restarts the server when it stops answering                                                                                                   |
| Start with the machine          | If the server was running when the machine shut down, it starts it again                                                                                                                                        |
| Artifacts                       | Downloads straight from Cfx.re and goes back to the previous one if the new one crashes 3 times in 10 minutes. See [Artifacts and configuration](https://fivedash.fivex.gg/docs/en/server/artifacts-and-config) |
| server.cfg                      | Reads and writes the `.cfg` files in the server folder, keeping a copy of the previous one                                                                                                                      |
| Update itself                   | When a new version comes out, it downloads it, checks it and switches while the server is stopped or restarting                                                                                                 |

## Security

* **No open ports.** The agent calls FiveDash. Nobody from outside connects to it.
* **Only FiveDash's commands.** It doesn't open a shell, doesn't run programs, and only downloads artifacts from Cfx.re and its own updates, always checking the file.
* **Secrets stay on the machine.** `sv_licenseKey`, `steam_webApiKey`, `mysql_connection_string`, passwords and keys show as `********` on the panel and never leave the machine.
* **Its own Windows account.** The service runs as `NT SERVICE\FiveDashAgent`, with access only to the server folder and the agent's folder, not as an administrator.
* **Who can do what.** Give **Manage** on the **Console** only to people you'd give the machine to: console commands and resources run code on the server. See [Team and permissions](https://fivedash.fivex.gg/docs/en/dashboard/team-and-permissions).

## Change machines or remove it

| To                               | Do                                                                                                                                              |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| Install on another machine       | **Install on another machine** generates a new command. Once the new agent connects, the old one stops working                                  |
| Disconnect from FiveDash         | **Remove agent**. It stops taking commands right away and FXServer stays as it is                                                               |
| Take the service off the machine | Run the same install command with `-Uninstall` at the end. The agent's folder in `C:\ProgramData\FiveDash\Agent` is deleted only if you confirm |

## History

**Server → Agent → History** shows what was asked of the agent lately: who started, stopped, restarted, switched artifacts or saved a `.cfg`, and whether it worked.

## Frequently asked questions

### The panel shows Disconnected

Check that the machine is on and that the **FiveDash Agent** service is running (in Windows **Services**, or `Get-Service FiveDashAgent` in PowerShell). The agent reconnects by itself when the internet comes back.

### Can I keep using txAdmin?

Not at the same time. Two programs starting the same server fight over the port. Once the agent is installed, close txAdmin and use FiveDash's **Console**.

### Does the agent replace the fivedash resource?

No. The `fivedash` resource still handles what happens inside the game (whitelist, store, logs). The agent handles the server program. See [Install the resource](https://fivedash.fivex.gg/docs/en/getting-started/install-resource).

## Next steps

[Console, resources and players](https://fivedash.fivex.gg/docs/en/server/console-and-players)Follow the console and send commands.
[Artifacts and configuration](https://fivedash.fivex.gg/docs/en/server/artifacts-and-config)Switch the artifact and edit server.cfg.
