blob: d8c656b0789be88dc8837521fec147fdf3a905f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#!/bin/bash
# dispatch-api-wrapper.sh
# Wrapper script for running the Dispatch API outside of systemd.
# Install to /usr/bin/dispatch-api (chmod 755).
#
# Usage:
# dispatch-api # runs the server, inheriting the current environment
# dispatch-api --help # passes flags through to bun
set -euo pipefail
DISPATCH_CONF="/etc/dispatch/dispatch-api.conf"
DISPATCH_DIR="/opt/dispatch"
BUN="/usr/bin/bun"
ENTRY_POINT="packages/api/src/index.ts"
# Source the environment file if it exists
if [[ -f "$DISPATCH_CONF" ]]; then
# Export every variable defined in the conf file so child processes see them.
# Lines starting with '#' and blank lines are skipped automatically by bash's
# 'source' builtin.
set -o allexport
# shellcheck source=/etc/dispatch/dispatch-api.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" "$@"
|