From 60f56367dfc1e3c5095d034bed4fb4f572e32b55 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Wed, 27 May 2026 23:17:18 +0900 Subject: refactor(packaging): split into dispatch/dispatch-systemd/dispatch-s6, separate dispatch-electron, add bun-based frontend serve PKGBUILD is now a split package producing three .pkg.tar.zst files in one makepkg run: - dispatch base application files (/opt/dispatch), CLI wrappers (dispatch-api, dispatch-frontend), env configs (/etc/dispatch/dispatch-api.conf, /etc/dispatch/dispatch-frontend.conf) - dispatch-systemd systemd user units for dispatch-api + dispatch-frontend (conflicts with dispatch-s6) - dispatch-s6 s6-rc service pipelines (-srv + -log) for both services (conflicts with dispatch-systemd) The Electron desktop wrapper moved to its own self-contained PKGBUILD at packaging/electron/, producing dispatch-electron. It bundles its own copy of the frontend dist + electron entry points under /opt/dispatch-electron and does not depend on the base dispatch package, so users can install it standalone and point VITE_API_URL at any backend at build time. Files under packaging/ are now read directly from ${_projectdir}/packaging/ rather than via source=(); the two s6 service dirs share basenames (run, type) which would collide inside ${srcdir}. New frontend static server: packages/frontend/serve.ts uses Bun's built-in HTTP server (no extra runtime deps) with SPA fallback to index.html and path-traversal protection. PORT/HOST/DIST_DIR overridable via env. Exposed as 'bun run --cwd packages/frontend serve' and via /usr/bin/dispatch-frontend. Build scripts: - bin/build-pkg now prints the freshest built packages - bin/install-pkg installs dispatch + dispatch-systemd by default; accepts package names or --all; searches both packaging/ and packaging/electron/ - bin/build-pkg-electron new, builds the electron split - bin/build-pkg-windows replaces bin/windows-pkg; drops the hard-coded WSL copy step, just prints the win-unpacked path .gitignore extended to cover packaging/*.tar.zst and packaging/electron/{src,pkg,*.pkg.tar.zst,*.tar.zst}. --- packaging/dispatch-s6.install | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 packaging/dispatch-s6.install (limited to 'packaging/dispatch-s6.install') diff --git a/packaging/dispatch-s6.install b/packaging/dispatch-s6.install new file mode 100644 index 0000000..efa4c9b --- /dev/null +++ b/packaging/dispatch-s6.install @@ -0,0 +1,46 @@ +post_install() { + install -dm755 -o tradam -g tradam /var/log/dispatch-api + install -dm755 -o tradam -g tradam /var/log/dispatch-frontend + + echo "" + echo "==> Dispatch s6-rc services installed at /etc/s6/sv/" + echo " Service pipelines: dispatch-api (= dispatch-api-srv | dispatch-api-log)" + echo " dispatch-frontend (= dispatch-frontend-srv | dispatch-frontend-log)" + echo " To enable and start:" + echo " s6 repository sync" + echo " s6 set enable -I pull dispatch-api-srv dispatch-api-log" + echo " s6 set enable -I pull dispatch-frontend-srv dispatch-frontend-log" + echo " s6 set commit -f" + echo " s6 live install" + echo " s6-rc -u change dispatch-api" + echo " s6-rc -u change dispatch-frontend" + echo "" +} + +post_upgrade() { + install -dm755 -o tradam -g tradam /var/log/dispatch-api 2>/dev/null || true + install -dm755 -o tradam -g tradam /var/log/dispatch-frontend 2>/dev/null || true + + # Remove any stale legacy service dirs from the old (pre-srv/-log split) + # layout, which would otherwise confuse s6 repository sync. + for legacy in /etc/s6/sv/dispatch-api /etc/s6/sv/dispatch-frontend; do + if [ -d "$legacy" ] && [ -d "$legacy/log" ] && [ ! -e "$legacy/producer-for" ]; then + rm -rf "$legacy" + fi + done + + echo "" + echo "==> Dispatch s6 services upgraded." + echo " Restart:" + echo " s6-rc -d change dispatch-api && s6-rc -u change dispatch-api" + echo " s6-rc -d change dispatch-frontend && s6-rc -u change dispatch-frontend" + echo "" +} + +pre_remove() { + echo "" + echo "==> Stopping dispatch services..." + s6-rc -d change dispatch-api 2>/dev/null || true + s6-rc -d change dispatch-frontend 2>/dev/null || true + echo "" +} -- cgit v1.2.3