diff options
Diffstat (limited to 'packaging/s6/dispatch-api-srv/run')
| -rw-r--r-- | packaging/s6/dispatch-api-srv/run | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/packaging/s6/dispatch-api-srv/run b/packaging/s6/dispatch-api-srv/run new file mode 100644 index 0000000..5754e3d --- /dev/null +++ b/packaging/s6/dispatch-api-srv/run @@ -0,0 +1,29 @@ +#!/bin/sh +# dispatch-api service — runs the Dispatch backend API as the `tradam` user. +# stdout/stderr are piped to dispatch-api-log via the s6-rc pipeline. + +DISPATCH_CONF="/etc/dispatch/dispatch-api.conf" +DISPATCH_DIR="/opt/dispatch" + +if [ -f "$DISPATCH_CONF" ]; then + set -a + . "$DISPATCH_CONF" + set +a +fi + +cd "$DISPATCH_DIR" || exit 1 + +# Merge stderr into stdout so both get logged by the consumer. +exec 2>&1 + +# Drop privileges to tradam and run bun. +exec /usr/bin/s6-setuidgid tradam \ + /usr/bin/env \ + HOME=/home/tradam \ + USER=tradam \ + LOGNAME=tradam \ + PATH=/usr/local/bin:/usr/bin:/bin \ + NODE_ENV="${NODE_ENV:-production}" \ + PORT="${PORT:-18390}" \ + OPENCODE_API_KEY="${OPENCODE_API_KEY:-}" \ + /usr/bin/bun packages/api/src/index.ts |
