# Production deploy (systemd)

## Behaviour

On **every** service start (clean midnight restart, crash, or power loss recovery):

1. `git fetch` + `git reset --hard origin/<branch>`
2. `git pull --ff-only`
3. `npm install --omit=dev`
4. start `node --experimental-sqlite server/src/index.js`

Pull-on-crash is intentional so a fixed commit on origin can recover a bad build.

Player-facing midnight schedule (3-hour countdown toast) still lives in the Node
process: it detects that origin is ahead, warns players, then exits cleanly so
systemd runs the update script above.

## Install on the host

```bash
cd /srv/tile-mmo/current   # or your clone
sudo ./deploy/install-service.sh
```

Optional env overrides:

| Variable | Default |
|----------|---------|
| `TILE_MMO_REPO` | parent of `deploy/` |
| `TILE_MMO_USER` | `tilemmo` |
| `TILE_MMO_GIT_BRANCH` | `master` |

## Manual ops

```bash
sudo systemctl restart tile-mmo
journalctl -u tile-mmo -f
```

Disable the in-process schedule locally with `TILE_MMO_DEPLOY_SCHEDULER=0`.
