Spring
[SpringBoot] nginx 무중단 배포하기
iheeeee6-6
2023. 2. 15. 15:14
728x90
1. 현재 nginx가 8081포트로 실행하고 있는 스프링 프로젝트를 바라보고 있음.(profile.sh)
2. 바라보고 있지 않은 8082포트로 배포를 진행하고(start.sh), 정상 구동중인지 확인.(health.sh)
3. nginx가 새롭게 배포된 8082포트로 바라보도록 한다.(switch.sh)
nginx를 설치하여 설정합니다.
1) sudo vim /etc/nginx/conf.d/service-url.inc
-> set $service_url http://127.0.0.1:8081;
2) sudo vim /etc/nginx/nginx.conf
3) appspec.yml
version: 0.0
os: linux
files:
- source: /
destination: /home/ec2-user/app/step3/zip/
overwrite: yes
permissions:
- object: /
pattern: "**"
owner: ec2-user
group: ec2-user
hooks:
AfterInstall:
- location: stop.sh #엔진엑스와 연결되어 있지 않은 스프링부트를 종료
timeout: 60
runas: ec2-user
ApplicationStart:
- location: start.sh #엔진엑스와 연결되어 있지 않은 Port로 새버전의 스프링부트를 시작
timeout: 60
runas: ec2-user
ValidateService:
- location: health.sh #새 스프링부트가 정상적으로 실행됐는지 확인
timeout: 60
runas: ec2-user
4) 8081 포트로 무중단 배포 완료