#!/bin/sh set -e # 数据库文件路径(可根据实际环境调整) DB_FILE=./database/db.sqlite3 # 检查 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 $RUNNER npx knex seed:run else echo "Database exists, running migration only..." $RUNNER npx knex migrate:latest fi # 启动主服务 $START