summaryrefslogtreecommitdiffhomepage
path: root/packaging/dispatch-frontend-wrapper.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/dispatch-frontend-wrapper.sh')
-rwxr-xr-xpackaging/dispatch-frontend-wrapper.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/packaging/dispatch-frontend-wrapper.sh b/packaging/dispatch-frontend-wrapper.sh
new file mode 100755
index 0000000..06aa9b0
--- /dev/null
+++ b/packaging/dispatch-frontend-wrapper.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# dispatch-frontend-wrapper.sh
+# Wrapper script for running the Dispatch Frontend static-file server
+# outside of systemd / s6.
+# Install to /usr/bin/dispatch-frontend (chmod 755).
+#
+# Usage:
+# dispatch-frontend # runs the server, inheriting the current environment
+# dispatch-frontend --help # passes flags through to bun
+
+set -euo pipefail
+
+DISPATCH_CONF="/etc/dispatch/dispatch-frontend.conf"
+DISPATCH_DIR="/opt/dispatch"
+BUN="/usr/bin/bun"
+ENTRY_POINT="packages/frontend/serve.ts"
+
+# Source the environment file if it exists
+if [[ -f "$DISPATCH_CONF" ]]; then
+ set -o allexport
+ # shellcheck source=/etc/dispatch/dispatch-frontend.conf
+ source "$DISPATCH_CONF"
+ set +o allexport
+fi
+
+# Change to the application directory
+cd "$DISPATCH_DIR"
+
+# Hand off to bun — exec replaces this process so signals are forwarded correctly
+exec "$BUN" "$ENTRY_POINT" "$@"