- TypeScript 95.2%
- Shell 3.1%
- Dockerfile 0.8%
- JavaScript 0.5%
- CSS 0.3%
- Other 0.1%
|
|
||
|---|---|---|
| .gitea/workflows | ||
| demo | ||
| docs/superpowers | ||
| web | ||
| .containerignore | ||
| .gitignore | ||
| app-config.test.ts | ||
| app-config.ts | ||
| artwork-fetch.test.ts | ||
| artwork-fetch.ts | ||
| ARTWORK.md | ||
| bios-deps.test.ts | ||
| bios-deps.ts | ||
| bun.lock | ||
| cabinet-config.test.ts | ||
| cabinet-config.ts | ||
| catalog-fetch.ts | ||
| catalog.ts | ||
| Containerfile | ||
| deluge-web.ts | ||
| DELUGE_USER_SETUP.md | ||
| download-progress.test.ts | ||
| download-progress.ts | ||
| emulator-config.test.ts | ||
| emulator-config.ts | ||
| fetch-artwork.sh | ||
| install-services.sh | ||
| installed-live.test.ts | ||
| installed-live.ts | ||
| installed-manifest.test.ts | ||
| installed-manifest.ts | ||
| mame-datfile.test.ts | ||
| mame-datfile.ts | ||
| mame-monitor.service | ||
| mame-monitor.timer | ||
| mame-scraper.service | ||
| mame-scraper.timer | ||
| mame-web.service | ||
| mnt-mame.mount | ||
| monitor-cli.ts | ||
| monitor-deluge.ts | ||
| package.json | ||
| post-scrape.ts | ||
| postcss.config.js | ||
| README.md | ||
| refresh-cli.ts | ||
| rom-config.test.ts | ||
| rom-config.ts | ||
| rom-copy-progress.test.ts | ||
| rom-copy.test.ts | ||
| rom-copy.ts | ||
| rom-datfile.ts | ||
| rom-deps.test.ts | ||
| rom-deps.ts | ||
| rom-dest-write.test.ts | ||
| rom-dest.test.ts | ||
| rom-dest.ts | ||
| rom-download.test.ts | ||
| rom-download.ts | ||
| rom-index-job.test.ts | ||
| rom-index-job.ts | ||
| rom-index.test.ts | ||
| rom-index.ts | ||
| rom-layers.test.ts | ||
| rom-layers.ts | ||
| rom-place.test.ts | ||
| rom-place.ts | ||
| rom-query.test.ts | ||
| rom-query.ts | ||
| rom-selection.test.ts | ||
| rom-selection.ts | ||
| rom-sources.test.ts | ||
| rom-sources.ts | ||
| romlist-refresh.test.ts | ||
| romlist-refresh.ts | ||
| scrape-cli.ts | ||
| scrape.ts | ||
| server.ts | ||
| tailwind.config.cjs | ||
| torrent-index.test.ts | ||
| torrent-index.ts | ||
| tsconfig.json | ||
| tsconfig.node.json | ||
| uninstall-services.sh | ||
| vite.config.ts | ||
| wheel-fetch.ts | ||
| wheel-index.test.ts | ||
| wheel-index.ts | ||
MAME Torrent History Tracker
A system to scrape and track MAME torrent links from PleasureDome GitHub Pages, organized by category and version.
Installation Location
All files are installed in /opt/mame-tracker/:
/opt/mame-tracker/
├── server.ts # Bun HTTP server: SPA + scrape + /api/refresh + JSON
├── scrape.ts # PleasureDome HTML scraper (cheerio)
├── post-scrape.ts # New version → Deluge Web UI + ROM datfile
├── deluge-web.ts # Deluge JSON-RPC helpers
├── rom-datfile.ts # dir2dat zip download + install
├── refresh-cli.ts # Full pipeline CLI (for systemd timer)
├── scrape-cli.ts # Scrape-only CLI
├── monitor-deluge.ts # Completed-torrent cleanup (Deluge Web UI)
├── monitor-cli.ts # CLI for monitor (systemd)
├── web/ # React + Vite + Tailwind (shadcn-style UI)
│ ├── src/
│ └── dist/ # Production build output (from `bun run build`)
├── package.json
├── mame-scraper.service
├── mame-scraper.timer
├── mame-web.service
├── mnt-mame.mount
├── install-services.sh
└── uninstall-services.sh
Running as a container: what to mount, and where
The bare-metal install above is one way to run this. The other is the published
image, which is how a cabinet runs it — git.forked.io/charles/mame-sync:latest,
started by arcade-nix's services.rom-manager module.
Nothing below is discovered. Every path is an environment variable with a default, and a container that is missing one of these mounts does not fail loudly — it reports an empty collection, or an emulator checklist full of sample data, both of which look like the application working.
| Mount at | Env var | Read/write | What it is |
|---|---|---|---|
| the source path itself | ROM_SOURCE_ROOT |
rw | The collection: base set, update packs, CHDs, bios/, MAME-Set.xml. Read-write because the scraper installs a refreshed datfile back into it. |
| the destination path itself | ROM_DEST_PATH |
rw | The play set. Only with ROM_DEST_KIND=fs. |
| — | ROM_DEST_LAYOUT |
— | nested (default): sets in roms/, BIOS in bios/. flat: sets in the destination itself, BIOS still in bios/ — for a destination already named after the emulator, where …/roms/mame/roms reads like a mistake. |
/data |
ROM_DATA_DIR |
rw | Generated state: the ROM index, catalogs, saved selections, copy progress. A volume, or a restart costs a 44k-row index rebuild. |
/etc/cabinet |
CABINET_MANIFEST (…/available-packages.json) |
ro | Which packages the host can install. Read-only on purpose: this UI renders the list, it does not define it. |
/etc/cabinet |
CABINET_EMULATORS (…/emulators.json) |
ro | Which systems the host can configure as emulators, what each currently says, and which fields may be written back. Same mount, same reason. |
/var/lib/cabinet |
CABINET_CONFIG_FILE (…/config.json) |
rw | The configuration tab's only channel to the host. The UI writes the operator's choices here and the host picks them up and rebuilds. |
/etc/samba/credentials |
ROM_SMB_CREDS |
ro | Only when copying to a different machine over SMB (ROM_DEST_KIND=smb, the default). Not used on a Linux cabinet. |
The two /…/cabinet mounts are a deliberate split. The container can write
what it wants but cannot apply it: /etc/cabinet is read-only and the host
rebuilds from /var/lib/cabinet/config.json on its own schedule. That is what
makes "the web UI cannot reconfigure the machine out from under you" enforced
rather than merely intended, and it is why the two are separate paths instead
of one directory.
Mount the ROM paths at the same path inside the container as outside. The
UI reports paths back to the operator, and a container that calls the
collection /mnt/mame while the host calls it /srv/arcade/collection produces
error messages naming a directory that does not exist on the machine reading
them.
Wait for the share before starting. Where a path is a network mount, a
container that starts first bind-mounts the empty directory underneath it and
then reports an empty collection while the share is mounted perfectly. Under
systemd that is RequiresMountsFor= on the container unit; arcade-nix sets it
from the storage areas.
podman run -d --name rom-manager -p 8080:80 \
-v /srv/arcade/collection:/srv/arcade/collection \
-v /srv/arcade/roms/mame:/srv/arcade/roms/mame \
-v rom-manager-data:/data \
-v /etc/cabinet:/etc/cabinet:ro \
-v /var/lib/cabinet:/var/lib/cabinet \
-e ROM_SOURCE_ROOT=/srv/arcade/collection \
-e ROM_DEST_KIND=fs \
-e ROM_DEST_PATH=/srv/arcade/roms/mame \
-e CABINET_MANIFEST=/etc/cabinet/available-packages.json \
-e DELUGE_URL=http://host.containers.internal:8112 \
-e DELUGE_TORRENT_LABEL=mame \
--env-file /etc/rom-manager/deluge-password.env \
git.forked.io/charles/mame-sync:latest
CABINET_MANIFEST is set explicitly even though the image has a default. The
image ships a sample manifest so the checklist renders in a bare container, and
without this line that fixture wins on a real cabinet too — showing sample data
as though it were the built system. DELUGE_PASSWORD goes in the env file,
never in -e: anything on the command line is visible in podman inspect and,
under Nix, in the world-readable store.
NFS: MAME library on the NAS
The install script enables a systemd mount that connects your MAME folder on the NAS:
| NAS export | 10.2.0.10:/volume1/Main/Emulation/MAME |
| Local mount point | /mnt/mame |
| Unit | mnt-mame.mount |
Requires nfs-common (Debian/Ubuntu) or nfs-utils (RHEL); install-services.sh tries to install it via apt-get or dnf/yum.
# Status and logs
systemctl status mnt-mame.mount
journalctl -u mnt-mame.mount -b
# Remount after NAS maintenance
sudo systemctl restart mnt-mame.mount
Synology: Enable NFS on the shared folder and grant this host access (read/write as needed). If the mount fails with “wrong version”, edit mnt-mame.mount and add e.g. nfsvers=3 or nfsvers=4 to the Options= line, then systemctl daemon-reload && systemctl restart mnt-mame.mount.
To install only the mount unit (no full app reinstall):
sudo mkdir -p /mnt/mame
sudo cp /opt/mame-tracker/mnt-mame.mount /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now mnt-mame.mount
Services Status
Check if services are running:
systemctl status mame-scraper.timer
systemctl status mame-web.service
Accessing the Web Interface
The Bun server listens on port 80 and serves the React app (shadcn-style components: Radix + Tailwind):
| Resource | URL |
|---|---|
| Tracker UI | http://YOUR_SERVER_IP/ |
| Same app (legacy paths) | http://YOUR_SERVER_IP/mame-tracker/, http://YOUR_SERVER_IP/mame-sync/ |
| History JSON | http://YOUR_SERVER_IP/mame_torrent_history.json |
| Refresh (runs scraper) | GET or POST http://YOUR_SERVER_IP/api/refresh |
| Latest ROM dat XML (download) | GET (or HEAD) http://YOUR_SERVER_IP/api/mame-set.xml |
| Latest XML metadata (JSON) | GET http://YOUR_SERVER_IP/api/mame-set/info |
| Game catalog — built versions | GET http://YOUR_SERVER_IP/api/games/versions |
| Game catalog — one game | GET http://YOUR_SERVER_IP/api/games/<version>/<zip> |
| Game catalog — group / list | GET http://YOUR_SERVER_IP/api/games/<version>?zips=a,b or ?search=&status=&limit=&offset= |
| Settings — read | GET http://YOUR_SERVER_IP/api/config |
| Settings — change | PUT http://YOUR_SERVER_IP/api/config |
| Settings — reload from disk | POST http://YOUR_SERVER_IP/api/config/reload |
| Settings — test Deluge | POST http://YOUR_SERVER_IP/api/config/test |
| Cabinet packages — read / select | GET / PUT http://YOUR_SERVER_IP/api/cabinet/packages |
| Cabinet emulators — read / configure | GET / PUT http://YOUR_SERVER_IP/api/cabinet/emulators |
The settings endpoints are covered in
Configuration file (and where to mount it)
below — including which file they read, where to mount it, and why an external
writer has to call /api/config/reload.
The XML endpoints stream / describe the same MAME-Set.xml the post-scrape pipeline installs into the NFS MAME dir (MAME_DAT_DEST/MAME_DAT_XML_NAME); it is overwritten in place on every new version, so these always reflect the latest. /api/mame-set/info returns { available, filename, path, version, size, modified } (version is read from the Logiqx <header><version>); both return 404 with available: false if the file isn't present yet.
Configuration file (and where to mount it)
Runtime settings an operator can change live in a JSON file. Inside the container that file is:
/data/config.json
/data is ROM_DATA_DIR, declared as a VOLUME in the Containerfile. Mount
a host directory there and the file is reachable from outside:
podman run -v /var/lib/rom-manager:/data ... # -> /var/lib/rom-manager/config.json
A cabinet already does this: services.rom-manager in charles/arcade-nix
mounts ${cfg.dataDir}:/data, and dataDir defaults to /var/lib/rom-manager,
so the file is at /var/lib/rom-manager/config.json on the host with no extra
work.
Note /data also holds generated state — ROM index, fetched catalogs, copy
progress — so it is a directory the application writes to, not a config-only
mount.
Shape
Absent means "all defaults"; the file is created on first save. Only keys present are treated as set:
{
"deluge": {
"url": "http://127.0.0.1:8112",
"password": "deluge",
"label": "mame"
}
}
Three layers decide each value, most specific first: saved file → environment
variable → built-in default. Clearing a key makes that value fall back a
layer rather than become empty. GET /api/config reports which layer supplied
each value in its sources object, which is the quickest way to confirm an edit
landed.
Making an external edit take effect
Settings are cached in memory, so a service that writes the file directly must say when it is done:
curl -X POST http://YOUR_SERVER_IP/api/config/reload
The response echoes the values now in force plus their sources, so the caller
can verify rather than assume — a value still reading env or default means
the file did not carry it. Without this call the edit is ignored until the
process restarts.
Game catalog API (per-version game metadata)
/api/games/... serves a per-game catalog — zip (set) name, game name, and emulation quality (plus year/manufacturer/clone) — for each MAME version this server has pulled & compiled (the no-nag builds). See catalog.ts.
<version>accepts a dotted version (0.288), the bare number (288), or the build tag (mame0288).- Zip lookups accept real non-merged filenames: a trailing
.zipand any case are fine (pacman.zip,PUCKMAN.ZIP, or barepacman). In a non-merged set every parent and clone has its own<setname>.zip, and each catalog entry'szipfield is that set name — so they map 1:1. - One game:
GET /api/games/0.288/pacman.zip→{ zip, name, status, emulation, year, manufacturer, cloneof, sourcefile }. - A group:
GET /api/games/0.288?zips=puckman.zip,dkong.zip,mario. - A filtered list:
GET /api/games/0.288?search=street&status=good&limit=50&offset=0(status ∈good|imperfect|preliminary; defaultlimit200, max 50000). - Versions available:
GET /api/games/versions. Unknown/unbuilt versions return404with the list of available ones.
How it's produced: the data is extracted statically from MAME source (the GAME/GAMEL/CONS/COMP/SYST macros), not by running a binary. status ("emulation quality") uses the exact good/imperfect/preliminary rule from MAME's own infoxml.cpp output_driver. It is generated automatically for every new version: the nightly scraper triggers a no-nag build (post-scrape.ts → triggerNoNagBuild), and build.sh writes builds/<tag>/catalog.json (~7.6 MB, ~38k games, ~1.6 s) as soon as the source is downloaded — before the multi-hour compile, so a new version is catalogued the moment it's pulled and even if the build later fails. The server loads it into memory on first request (sub-millisecond lookups thereafter). To (re)generate manually:
bun run catalog -- /path/to/mame-source/src/mame mame0288 # -> builds/mame0288/catalog.json
This static parse faithfully captures the declarative layer (name, zip, year, manufacturer, clone, driver flags) but not runtime-computed detail (dipswitches, device-provided ROMs, displays) — those would require a running binary's -listxml. Coverage note: every game and BIOS set is included (BIOS roots are GAME(...) macros), but standalone device-ROM zips (e.g. qsound) are not — devices are defined via DEVICE_*, not the GAME-family macros, so they don't appear as catalog entries.
Set MAME_WEB_PORT in the systemd unit if you need a port other than 80.
Development
- Install Bun if needed.
- Terminal A — API + JSON (port 8080):
MAME_WEB_PORT=8080 bun run server.ts - Terminal B — Vite dev server with proxy:
bun run dev(opens port 5173; proxies/apiand JSON to 8080).
ROM datfile (dir2dat) → MAME-Set.xml
When a new MAME version is processed (after each refresh that detects a new version), the Bun post-step also:
- Resolves the MAME ROMs dat zip URL (from scraped history, or standard GitHub paths under PleasureDome).
- Downloads it, extracts the zip, and picks the non-merged or merged
.xml(or ClrMamePro.datXML) perMAME_ROM_DAT_VARIANT. - Copies it to the NFS MAME directory as a fixed name (default
MAME-Set.xml).
| Environment variable | Default | Meaning |
|---|---|---|
MAME_DAT_DEST |
/mnt/mame |
Target directory (NFS mount) |
MAME_DAT_XML_NAME |
MAME-Set.xml |
Output filename |
MAME_ROM_DAT_VARIANT |
non-merged |
non-merged or merged — which PleasureDome ROM set zip/XML to install |
ROM_DATFILE_GITHUB_BASE |
PleasureDome raw/gh-pages/mame/ |
Fallback URL prefix |
mame-scraper.service starts after mnt-mame.mount so /mnt/mame is available.
No-nag MAME builds
When the scraper detects a new MAME version, the post-scrape pipeline also kicks off a Windows-x64 no-nag build of MAME from upstream source. Output is a single drop-in mame.exe, kept locally under /opt/mame-tracker/no-nag/builds/<tag>/.
What "no-nag" means here
A one-line patch in src/frontend/mame/ui/ui.cpp flips bool show_warnings = true; to false inside mame_ui_manager::display_startup_screens(...). Result: the orange/red emulation-warning popup never renders. Game-info, mandatory-image errors, and everything else are untouched. Using a binary built from this patched source means MAMEdev will not support bug reports — that's the point.
Layout
/opt/mame-tracker/no-nag/
├── apply-no-nag.sh # idempotent patcher; fails loudly if MAME refactors
├── build.sh # download → patch → cross-compile → install
├── check-and-build.sh # CLI: resolve mamedev/mame latest, build if new
├── builds/<tag>/mame.exe # successful artifacts
├── logs/<tag>.log # full build log, tail visible at /api/no-nag/log/<tag>
├── work/<tag>/ # transient build dir, removed on exit
├── .build.lock # flock-based single-flight gate
└── .last-built # last successful tag (e.g. mame0287)
Trigger model
- Automatic:
post-scrape.tscallstriggerNoNagBuild(latestVersion)after a new version is recorded; the build runs detached so the HTTP refresh returns immediately. See no-nag-trigger.ts. - Manual:
/opt/mame-tracker/no-nag/build.sh mame0287orcheck-and-build.sh(the latter resolves "latest" from the GitHub release). - Opt-out: set
NO_NAG_BUILD=0in the scraper service environment to disable the auto-trigger.
build.sh is idempotent: if builds/<tag>/mame.exe already exists, it returns 0 immediately. A flock-protected single-flight prevents overlap if a build is already in progress.
HTTP endpoints
| Method | Path | Returns |
|---|---|---|
GET |
/api/no-nag/builds |
JSON list of all builds + status (success / in-progress / failed) |
GET |
/api/no-nag/download/<tag> |
mame-<tag>-no-nag.exe for completed builds |
GET |
/api/no-nag/log/<tag> |
Last 64 KB of the build log (text/plain) |
The tracker UI surfaces this via the No-nag MAME builds panel — a list of versions with download buttons and an in-progress badge while a build is running.
Toolchain
Cross-compile from this Linux host using MinGW-w64 (POSIX threads, GCC 14+):
sudo apt-get install -y --no-install-recommends \
g++-mingw-w64-x86-64-posix gcc-mingw-w64-x86-64-posix \
binutils-mingw-w64-x86-64 python3 make jq
Build invocation (set inside build.sh):
make TARGETOS=windows PTR64=1 MINGW64=/usr \
OVERRIDE_CC=x86_64-w64-mingw32-gcc \
OVERRIDE_CXX=x86_64-w64-mingw32-g++ \
OVERRIDE_LD=x86_64-w64-mingw32-ld \
PYTHON_EXECUTABLE=/usr/bin/python3 -j$(nproc)
Resource note
A full MAME build is heavy: ~3–4 GB of source extracted, ~25–30 GB of build artifacts at peak, ~6–12 GB RAM peak per gcc, multiple hours wall time even with -j6. Make sure the host has 16+ GB RAM and 100+ GB free under /opt. The work/<tag>/ tree is removed on a clean exit.
SMB publish
After a successful build, publish.sh pushes mame.exe to a Windows SMB share. Defaults match the user's arcade rig: //arcadepc/d/Arcade/MAME/emulator/mame.exe, overwriting the existing file.
The destination is typically locked while MAME is running on the arcade rig (NT_STATUS_SHARING_VIOLATION), so publish.sh is a retry daemon: it loops with a 5-min sleep until the lock clears, the destination becomes reachable, the daily cap hits, or a newer publish supersedes it. build.sh spawns it via setsid so the build slot isn't tied up by hours of polling.
Failure classification:
| smbclient output | Treated as | Behavior |
|---|---|---|
NT_STATUS_LOGON_FAILURE, NT_STATUS_ACCESS_DENIED, NT_STATUS_ACCOUNT_* |
auth failure | exit 2 immediately, no retry |
NT_STATUS_SHARING_VIOLATION |
destination locked (MAME running) | retry every RETRY_INTERVAL_SEC |
Connection ... failed, NT_STATUS_HOST_UNREACHABLE, NT_STATUS_IO_TIMEOUT, … |
network unavailable | retry |
| anything else | transient | retry |
If a newer publish is invoked (e.g. mame0288 finishes while mame0287 is still polling because MAME has been running for 6 hours), the newer one kills the older retry and takes over — we always ship the most recent build.
Configuration (env, defaults shown):
| Env var | Default | Purpose |
|---|---|---|
NO_NAG_SMB_TARGET |
//arcadepc/d |
UNC //host/share |
NO_NAG_SMB_SUBPATH |
Arcade/MAME/emulator |
Path inside the share (forward slashes) |
NO_NAG_SMB_CREDS |
/etc/samba/credentials.no-nag |
Samba creds file (mode 600) |
NO_NAG_SMB_DEST_NAME |
mame.exe |
Remote filename |
NO_NAG_PUBLISH_RETRY_SEC |
300 |
Sleep between attempts |
NO_NAG_PUBLISH_MAX_ATTEMPTS |
288 |
Give-up cap (≈ 24 h × 5 min) |
Credentials file format:
username=cdaoust
password=...
domain=WORKGROUP
publish-<tag>.log lives in /opt/mame-tracker/no-nag/logs/ for the detached retry runs. If NO_NAG_SMB_CREDS is missing, the publish step is skipped silently.
# Push an already-built version manually (retries until destination is unlocked):
sudo /opt/mame-tracker/no-nag/publish.sh mame0287
Service Management
View Logs
# Scraper logs
journalctl -u mame-scraper.service -f
# Web server logs
journalctl -u mame-web.service -f
Manual Operations
# Manually run the scraper
systemctl start mame-scraper.service
# Restart web server
systemctl restart mame-web.service
# Stop web server
systemctl stop mame-web.service
Check Timer Schedule
systemctl list-timers mame-scraper.timer
systemctl list-timers mame-monitor.timer
- The scraper runs daily at 2 AM UTC
- The Deluge monitor runs every 15 minutes to check for completed MAME torrents
Automatic Deluge Integration
The Bun post-step (after each successful scrape) can add MAME Update ROMs and MAME Update CHDs magnets to Deluge when a new version is detected. The tracker UI uses the same Deluge Web UI JSON-RPC (DELUGE_URL) to show what is already in the client.
Configuration
The URL, password and torrent label can be edited at runtime from the Configuration tab in the web UI — changes apply immediately, no restart needed. That's the preferred way to change them.
They resolve in three layers, most specific wins:
- Saved config — written by the Configuration tab to
${ROM_DATA_DIR}/config.json(inside this app's own data directory; never touches the NixOS cabinet config) - Environment — set in
mame-scraper.service,mame-web.service, or your shell (not the old daemon RPC host/port) - Built-in defaults — Deluge's own defaults for a local install (
http://127.0.0.1:8112, passworddeluge, labelmame), so a cabinet running Deluge on the same machine needs no configuration at all
| Variable | Meaning |
|---|---|
DELUGE_URL |
Web UI base, e.g. http://127.0.0.1:8112 |
DELUGE_PASSWORD |
Web UI password (empty string if none) |
DELUGE_TORRENT_LABEL |
Label for new torrents (default mame) |
DELUGE_WEB_URL |
Optional browser URL for “Open Deluge” in the UI (defaults to the resolved Deluge URL above). Environment-only — not editable from the Configuration tab. |
Example:
Environment="DELUGE_URL=http://127.0.0.1:8112"
Environment="DELUGE_PASSWORD=your_web_ui_password"
Then: sudo systemctl daemon-reload && sudo systemctl restart mame-scraper.service mame-web.service
How It Works
- When a new latest version appears vs
.last_processed_version, the pipeline adds Update ROMs + Update CHDs magnets viacore.add_torrent_magnet, then runs the ROM datfile install. - The Label plugin is optional but recommended for labels and for the completion monitor.
Manual Testing
curl -sS -X POST "http://127.0.0.1/api/refresh"
# or full pipeline without HTTP:
cd /opt/mame-tracker && bun run refresh
Data Storage
The JSON data file is stored at:
/opt/mame-tracker/mame_torrent_history.json
This file is automatically created and updated by the scraper (bun run scrape, bun run refresh, or /api/refresh).
Dependencies
- Bun — runtime for the server, scraper, monitor, and CLIs (
bun installinstallscheerio,fflate, etc.).
Standalone binary (optional)
After bun install && bun run build:
bun run build:server
# produces ./mame-tracker — single executable with embedded Bun runtime
Automatic Torrent Removal
The system includes a monitor that automatically pauses completed torrents that have the mame label (or DELUGE_TORRENT_LABEL) only; other torrents are not touched.
How It Works
- Labeling: When torrents are added to Deluge, they are automatically labeled with
mame - Monitoring: A background service checks every 15 minutes for completed torrents with the
mamelabel - Removal: When a torrent finishes downloading (reaches 100% or enters "Seeding" state), it is removed from Deluge but files remain on disk
Monitor Service
- Service:
mame-monitor.service - Timer:
mame-monitor.timer(runs every 15 minutes) - CLI:
bun run monitoror/usr/bin/bun /opt/mame-tracker/monitor-cli.ts - Uses
DELUGE_URL/DELUGE_PASSWORD(Web UI JSON-RPC), same as the tracker. MatchesDELUGE_TORRENT_LABELonly (no owner filter).
Manual Operations
# Manually run the monitor
systemctl start mame-monitor.service
# Or from the repo
cd /opt/mame-tracker && bun run monitor
# Check monitor status
systemctl status mame-monitor.timer
# View monitor logs
journalctl -u mame-monitor.service -f
Requirements
- Label Plugin: Must be enabled in Deluge for labeling to work
- The monitor will skip torrents without the
mamelabel - Files are preserved on disk when torrents are removed
Troubleshooting
Scraper not running
Check logs:
journalctl -u mame-scraper.service -n 50
Common issues:
- Missing JS deps:
cd /opt/mame-tracker && bun install && bun run build - Network issues: Check internet connectivity (scraper fetches PleasureDome + GitHub)
- ROM dat: Ensure
MAME_DAT_DESTexists and is writable (NFS mounted)
Web server not accessible
- Check if running:
systemctl status mame-web.service - Check logs:
journalctl -u mame-web.service -f - Check firewall: May need to allow port 80
- Verify port: Check if port 80 is already in use (requires root privileges)
- Note: Port 80 requires root privileges. The service runs as root by default.
Reinstall Services
If you need to reinstall the services:
cd /opt/mame-tracker
bash uninstall-services.sh
bash install-services.sh