You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

28 lines
650 B

#!/bin/sh
set -e
# 数据库文件路径(可根据实际环境调整)
DB_FILE=./database/db.sqlite3
ENV=${NODE_ENV:-production}
# 检查 bun 是否存在
if command -v bun >/dev/null 2>&1; then
RUNNER="bun run"
START="exec bun src/main.js"
else
RUNNER="npx"
START="exec npm run start"
fi
# 如果数据库文件不存在,先 migrate 再 seed
if [ ! -f "$DB_FILE" ]; then
echo "Database not found, running migration and seed..."
$RUNNER npx knex migrate:latest --env $ENV
$RUNNER npx knex seed:run --env $ENV
else
echo "Database exists, running migration only..."
$RUNNER npx knex migrate:latest
fi
# 启动主服务
$START