21 lines
442 B
Bash
21 lines
442 B
Bash
|
|
#!/bin/sh
|
||
|
|
set -eu
|
||
|
|
|
||
|
|
backend_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||
|
|
cd "$backend_dir"
|
||
|
|
|
||
|
|
if [ ! -f .env ]; then
|
||
|
|
printf '%s\n' '缺少 backend/.env,请先从 .env.example 复制并配置。' >&2
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Only source trusted local configuration; .env uses shell assignment syntax.
|
||
|
|
set -a
|
||
|
|
. ./.env
|
||
|
|
set +a
|
||
|
|
|
||
|
|
go build -o bin/api ./cmd/server
|
||
|
|
# Replace the shell so shutdown signals reach the Go process directly.
|
||
|
|
exec ./bin/api
|
||
|
|
|