Files
jaryo/start-service.sh
COMTREE d3d8aa48b6
Some checks failed
Deploy to Vercel / deploy (push) Has been cancelled
Deploy to Railway / deploy (push) Has been cancelled
cleanup: remove MariaDB dependencies and files
- Remove MariaDB helper, schema, and initialization script
- Remove mysql2 dependency from package.json
- Update reset-admin.js to use SQLite DatabaseHelper
- Simplify .env.example to remove MariaDB configuration
- Update start-service.sh to use SQLite initialization
- Clean up all MariaDB references across codebase

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-25 14:08:44 +09:00

82 lines
2.1 KiB
Bash
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 시놀로지 NAS용 서비스 시작 스크립트
# 사용법: ./start-service.sh
# 프로젝트 디렉토리 설정 (실제 경로에 맞게 수정)
PROJECT_DIR="/volume1/web/jaryo"
LOG_FILE="/volume1/web/jaryo/logs/app.log"
PID_FILE="/volume1/web/jaryo/app.pid"
# 로그 디렉토리 생성
mkdir -p "$(dirname $LOG_FILE)"
# Node.js 경로 확인 (시놀로지 기본 설치 경로)
NODE_PATH="/volume1/@appstore/Node.js_v18/usr/local/bin/node"
if [ ! -f "$NODE_PATH" ]; then
NODE_PATH="node"
fi
# NPM 경로 확인
NPM_PATH="/volume1/@appstore/Node.js_v18/usr/local/bin/npm"
if [ ! -f "$NPM_PATH" ]; then
NPM_PATH="npm"
fi
echo "=== Jaryo File Manager 서비스 시작 ==="
echo "프로젝트 디렉토리: $PROJECT_DIR"
echo "Node.js 경로: $NODE_PATH"
echo "로그 파일: $LOG_FILE"
# 프로젝트 디렉토리로 이동
cd "$PROJECT_DIR" || {
echo "오류: 프로젝트 디렉토리를 찾을 수 없습니다: $PROJECT_DIR"
exit 1
}
# 의존성 설치 확인
if [ ! -d "node_modules" ]; then
echo "의존성 설치 중..."
$NPM_PATH install
fi
# SQLite 데이터베이스 초기화 (선택적)
if [ "$INIT_DB" = "true" ] && [ -f "scripts/init-database.js" ]; then
echo "SQLite 데이터베이스 초기화 중..."
if $NPM_PATH run init-db; then
echo "✅ SQLite 초기화 완료"
else
echo "⚠️ SQLite 초기화 실패"
fi
else
echo " 데이터베이스 초기화 건너뜀 (INIT_DB=true로 설정시 초기화)"
fi
# 기존 프로세스 종료
if [ -f "$PID_FILE" ]; then
OLD_PID=$(cat "$PID_FILE")
if kill -0 "$OLD_PID" 2>/dev/null; then
echo "기존 프로세스 종료 중 (PID: $OLD_PID)..."
kill "$OLD_PID"
sleep 2
fi
rm -f "$PID_FILE"
fi
# 서비스 시작
echo "서비스 시작 중..."
# NAS 환경 변수 설정 (SQLite 사용)
export NODE_ENV=production
export HOST=0.0.0.0
export PORT=3005
nohup $NODE_PATH server.js > "$LOG_FILE" 2>&1 &
NEW_PID=$!
# PID 저장
echo $NEW_PID > "$PID_FILE"
echo "서비스가 시작되었습니다. PID: $NEW_PID"
echo "로그 확인: tail -f $LOG_FILE"
echo "서비스 중지: kill $NEW_PID"