# User setup

How to get Windrose Server Manager running on the box where your Windrose dedicated server lives.

You can run the manager in **two modes**, and you don't have to commit upfront — switching between them is just a config change:

- **Local only** (simplest): the manager runs on your box, web UI at `http://localhost:8080`, no cloud connection. Use this if you only need a single-server admin panel and don't care about remote access. Setup is a 5-line config file with just your RCON password.
- **Connected to a hub** (optional): the manager *also* dials out to a cloud dashboard (the one I run at `windrose.certifriedmultitool.com` or your own — see [SELF_HOSTING.md](SELF_HOSTING.md)). Lets you manage one or more servers from anywhere. No port forwarding on your end — the connection is outbound-only.

This guide covers both. Skip ahead based on which you want.

---

## What you'll need

- A Windows 10 or Windows 11 machine running your Windrose dedicated server
- The dedicated server installed with the **WindroseRCON** mod (the `version.dll` injection that gives you Source-RCON access)
- Your RCON password and port (from the WindroseRCON mod config in the dedicated-server's `engine.ini`)
- (Optional, for cloud dashboard) An account at https://windrose.certifriedmultitool.com — sign up by email or Discord
- (Optional, for Discord notifications) A Discord channel webhook URL — server settings → Integrations → Webhooks → New Webhook → copy URL

You do **not** need to install .NET — the prebuilt EXE is self-contained.

---

## Step-by-step

### 1. Download and unzip

1. Download `WindroseServerManager-vX.Y.Z-win-x64.zip` from the [Releases page](#).
2. Right-click the zip → Properties → check "Unblock" if present, then OK. (Windows often blocks executables from the internet until you mark them safe.)
3. Unzip somewhere durable — for example `C:\WSM\`.

You should now have a folder containing:
```
WindroseServerManager.exe        ← the desktop app (double-click this)
WindroseServerManager.Web.exe    ← the underlying web server (auto-launched by the desktop app)
appsettings.json
appsettings.Local.minimal.json   ← copy → appsettings.Local.json for the simplest setup
appsettings.Local.example.json   ← full reference with all options
install-as-service.ps1
uninstall-service.ps1
run-console.bat                  ← run as a console process (no GUI window) — for headless boxes
wwwroot/                          ← static UI assets
```

### 2. Configure

There are **two example configs** in the zip:

- `appsettings.Local.minimal.json` — bare-minimum local-only setup. 5 lines. Just an RCON password. The web UI is wide open (no login) so use this only on a trusted machine where you're the only user.
- `appsettings.Local.example.json` — the full reference. Every option documented (auth, Discord channels, hub connection). Start with this one if you want any of those features.

#### Local-only mode (simplest)

1. Copy `appsettings.Local.minimal.json` → `appsettings.Local.json` (in the same folder).
2. Open it, replace `YOUR_RCON_PASSWORD_HERE` with your actual RCON password.
3. Save. That's it — skip step 3 below.

#### Full mode (auth + Discord + hub)

1. Copy `appsettings.Local.example.json` → `appsettings.Local.json`.
2. Fill in:

   **Required:**
   - `Rcon.Password` — your dedicated-server RCON password
   - `Auth.Password` — pick a strong password to gate the manager's web UI (or set `Auth.Required: false` if you don't want login)

   **Optional but recommended:**
   - `DiscordChannels[].WebhookUrl` — paste your Discord webhook URLs. Each channel is a logical name (`server-status`, `player-activity`, `announcements`); routing rules in `appsettings.json` map events to channels. Delete entries you don't want.
   - `Hub.Enabled` — set to `true` if you want the cloud dashboard (next step explains how to get a token)

3. Save the file.

### 3. (Skip if you're going local-only) Connect to the hub

If you want to manage your server from anywhere through the cloud dashboard:

1. Go to https://windrose.certifriedmultitool.com
2. Sign in — either click **Sign in with Discord** (one click, no password to remember) or use email/password sign-up. You can link the other method later from the Account page.
3. Click **Add server** → enter a name (e.g. "My Friday Coop") → **Create token**
4. **Copy the token immediately** — it's shown only once
5. Paste it into your `appsettings.Local.json`:
   ```json
   "Hub": {
     "Enabled": true,
     "Url": "wss://windrose.certifriedmultitool.com/api/agent",
     "AgentToken": "PASTE-HERE",
     "AgentName": "My Friday Coop"
   }
   ```
6. Save.

Within seconds of starting the manager (next step), your server will appear online in your hub dashboard. From the hub you can then click **Restart**, **Stop**, or send any RCON command from anywhere on the internet — no port forwarding needed on your end (the manager dials out to the hub).

### 4. Run

You have two options. Pick one.

#### Option A: Run the desktop app (recommended)

Double-click `WindroseServerManager.exe`. A native desktop window opens with the manager UI inside it. The app spawns the underlying server process in the background (no console window) and embeds the dashboard via WebView2 — so it looks and feels like any other Windows desktop app.

Closing the window cleanly stops everything.

If WebView2 isn't installed on this machine you'll get a one-time prompt with the download link (it's pre-installed on Windows 11 and recent Windows 10).

#### Option B: Run as a console app (headless boxes, debugging)

Double-click `run-console.bat`. A console window opens, logs scroll past. You'll see lines like:

```
[19:13:34 INF] BUS RconConnected ... Endpoint = 127.0.0.1:25575
[19:13:34 INF] Hub: connecting to wss://windrose.certifriedmultitool.com/api/agent
[19:13:34 INF] Hub: handshake OK with 'wsm-hub' (proto v1)
[19:13:34 INF] Now listening on: http://localhost:8080
```

Open http://localhost:8080 in a browser. Sign in with the password you set in `Auth.Password`. You should see the dashboard. Test a few things:

- Player list: matches `showplayers` from RCON
- Manual RCON console: try `info`
- Discord webhooks: in `/integrations` use the Test buttons

To stop, press `Ctrl+C` in the console window.

#### Option C: Install as a Windows service (recommended for production)

After confirming it works in console mode, install it as a service so it auto-starts on boot:

1. Right-click `install-as-service.ps1` → "Run with PowerShell" — when Windows prompts for elevation, click Yes.
2. The script copies the release files to `C:\Program Files\WindroseServerManager\app\` and creates a service named `WindroseServerManager` set to auto-start.
3. **Important**: copy your `appsettings.Local.json` from the release folder into `C:\Program Files\WindroseServerManager\app\` (the script doesn't move it because it might overwrite an existing one).
4. Start the service:
   ```powershell
   Start-Service WindroseServerManager
   ```
5. Open http://localhost:8080.

The service will now start automatically on boot and restart itself if it crashes.

---

## Troubleshooting

**"http://localhost:8080 doesn't load"**
The manager isn't running. If you used Option A, check the console window for errors. If you used Option B, run `Get-Service WindroseServerManager` — if Status is Stopped, start it; if it won't start, check `C:\Program Files\WindroseServerManager\app\logs\wsm-*.log` for the reason.

**"RCON authentication failed"**
The `Rcon.Password` in your `appsettings.Local.json` doesn't match what your dedicated server expects. Double-check the WindroseRCON mod's config in your dedicated-server install (usually `engine.ini` under a `[WindroseRCON]` section). Restart the manager after fixing.

**"Hub status shows 'connecting' forever"**
Either the token in `Hub.AgentToken` is wrong (regenerate at https://windrose.certifriedmultitool.com/agents/new), or your firewall blocks outbound port 443. The hub uses standard HTTPS — if your browser can reach the hub URL, the manager should too.

**"Discord shows nothing"**
Open `/integrations` in the manager UI and use the **Test** button next to each channel. If the test posts but real events don't, check the routing rules at `/routing` — events have to be mapped to channels.

**"Player list says 0 even though people are playing"**
The manager backfills players from the log on startup, but if the dedicated server was running long before the manager started, baseline players might be missed. They'll appear when they next leave/rejoin or send a `/say` chat message (if `/say` parsing is enabled).

**"I see two of the same login on the hub dashboard"**
You signed up with email and then signed in with Discord (different email on Discord), so the hub created two accounts. Sign in to the account you want to keep, click **Account** → **Link Discord** — the hub will detect the duplicate and offer to merge them (delete the other, transfer all agents).

**"I want to add a password to my Discord-only account"**
Sign in via Discord, click **Account** → fill in the "Set password" form. Useful as a backup in case Discord is down or you lose access to it.

---

## What if I want to manage multiple servers?

Run one manager per dedicated server, each in its own folder. They each get a separate hub token (one per server), so they show up as separate agents in your hub dashboard. The hub's per-user agent listing keeps them organized.

Different folders = different config = different ports if you want — set `Urls` in `appsettings.Local.json` to pick a different web-UI port:
```json
"Urls": "http://localhost:8081"
```

---

## Updating

When a new release comes out:

1. Stop the current manager:
   ```powershell
   Stop-Service WindroseServerManager
   ```
2. Download the new zip, unzip somewhere temporary.
3. Re-run `install-as-service.ps1` from the new folder — it re-copies files into `C:\Program Files\WindroseServerManager\app\`. Your `appsettings.Local.json` is preserved.
4. Start it again:
   ```powershell
   Start-Service WindroseServerManager
   ```

---

## Where things live

| Path                                                      | What it is                                              |
|-----------------------------------------------------------|---------------------------------------------------------|
| `C:\Program Files\WindroseServerManager\app\`             | Installed exe + assets (when using Option B)            |
| `<install>\appsettings.Local.json`                        | Your secrets (RCON password, hub token, Discord URLs)   |
| `<install>\logs\wsm-*.log`                                | Rolling log files (one per day)                         |
| `<install>\data\`                                         | Persisted state: routing rules, schedules, audit log    |
| `C:\Program Files (x86)\Steam\steamapps\common\Windrose Dedicated Server\R5\Saved\Logs\R5.log` | Dedicated-server log (tailed by manager) |
| Service name `WindroseServerManager` in `services.msc`    | Windows service entry                                   |
