diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/deploy_prod.yml index 3aeb286..4d96c0d 100644 --- a/.github/workflows/deploy_prod.yml +++ b/.github/workflows/deploy_prod.yml @@ -49,7 +49,7 @@ jobs: echo "ZIP_FILENAME=$ZIP_FILENAME" >> $GITHUB_ENV - name: zip create - run: zip -qq -r --symlinks ./${{ env.ZIP_FILENAME }} .next appspec.yml deploy.sh + run: zip -qq -r --symlinks ./${{ env.ZIP_FILENAME }} shell: bash - name: Configure AWS credentials diff --git a/appspec.yml b/appspec.yml index 49f04c9..7415e8b 100644 --- a/appspec.yml +++ b/appspec.yml @@ -12,5 +12,5 @@ permissions: hooks: ApplicationStart: - location: deploy.sh - timeout: 500 + timeout: 60 runas: ubuntu diff --git a/deploy.sh b/deploy.sh index 4fb6fad..a746303 100644 --- a/deploy.sh +++ b/deploy.sh @@ -5,5 +5,4 @@ cd /home/ubuntu/frontend # Start the application # Adjust the command below to suit your application's start process -yarn install -yarn dev \ No newline at end of file +yarn deploy \ No newline at end of file diff --git a/ecosystem.config.js b/ecosystem.config.js new file mode 100644 index 0000000..9708812 --- /dev/null +++ b/ecosystem.config.js @@ -0,0 +1,17 @@ +module.exports = { + apps: [ + { + name: 'i-tracker', // 앱의 이름 + script: './node_modules/next/dist/bin/next', // Next.js 스크립트 경로 + args: 'start', // Next.js 앱을 시작할 때 사용할 인수 + exec_mode: 'cluster', // 실행 모드: cluster 또는 fork 중 선택 + instances: '2', // 클러스터 모드에서 실행할 인스턴스 수 (CPU 코어 수만큼) + autorestart: true, // 프로세스 자동 재시작 활성화 + watch: true, // 파일 변경 감지 활성화 (개발 중에만 활용) + max_memory_restart: '1G', // 1GB 이상 메모리 사용 시 재시작 + env: { + NODE_ENV: 'production', // Node.js 환경 설정 + }, + }, + ], +}; diff --git a/package.json b/package.json index d92493c..8be8383 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "build": "next build", "start": "next start", "lint": "next lint", - "lint:fix": "next lint --fix" + "lint:fix": "next lint --fix", + "deploy": "pm2 start ecosystem.config.js --env production" }, "dependencies": { "@radix-ui/react-slot": "^1.0.2",