Skip to content

Commit

Permalink
chore: appspec 및 script파일 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchijinju committed Jul 20, 2024
1 parent 77a0a8f commit 7c0f867
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
8 changes: 8 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ permissions:
owner: ec2-user
group: ec2-user
hooks:
ApplicationStop:
- location: scripts/stop_server.sh
timeout: 300
runas: ec2-user
BeforeInstall:
- location: scripts/before_install.sh
timeout: 300
runas: ec2-user
ApplicationStart:
- location: scripts/start_server.sh
timeout: 300
Expand Down
3 changes: 3 additions & 0 deletions scripts/before_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
# Install PM2 globally
npm install -g pm2
10 changes: 3 additions & 7 deletions scripts/start_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ cd /home/ec2-user/build
npm install
npm run build

# 현재 실행중인 next.js 서버가 있다면 kill 하고 서버 새로 시작
PID=$(ps aux | grep 'next start -p 3000' | grep -v grep | awk '{print $2}')
if [ -n "$PID" ]; then
kill -9 $PID
fi

nohup npm run start &
# Start the application using PM2
pm2 start "npm run start" --name mejai
pm2 save
2 changes: 2 additions & 0 deletions scripts/stop_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
pm2 stop mejai

0 comments on commit 7c0f867

Please sign in to comment.