Closed dasd412 closed 2 years ago
참고 자료 (코드 디플로이 로그 알아내기) https://docs.aws.amazon.com/ko_kr/codedeploy/latest/userguide/deployments-view-logs.html
다음은 코드 디플로이 로그에서 얻어낸 로그다.
2022-03-24 11:14:55 LifecycleEvent - AfterInstall
2022-03-24 11:14:55 Script - stop.sh
2022-03-24 11:14:55 [stderr]/opt/codedeploy-agent/deployment-root/xxx/yyy/deployment-archive/stop.sh: line 5: soucre: command not found
2022-03-24 11:14:55 [stderr]/opt/codedeploy-agent/deployment-root/xxx/yyy/deployment-archive/stop.sh: line 7: find_idle_port: command not found
2022-03-24 11:14:55 [stdout]> 에서 running 중인 애플리케이션 pid check!
2022-03-24 11:14:55 [stderr]lsof: unacceptable port specification in: -i tcp:
2022-03-24 11:14:55 [stderr]lsof 4.87
2022-03-24 11:14:55 [stderr] latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
2022-03-24 11:14:55 [stderr] latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
2022-03-24 11:14:55 [stderr] latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
2022-03-24 11:14:55 [stderr] usage: [-?abhKlnNoOPRtUvVX] [+|-c c] [+|-d s] [+D D] [+|-f[gG]] [+|-e s]
2022-03-24 11:14:55 [stderr] [-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [+m [m]] [+|-M] [-o [o]] [-p s]
2022-03-24 11:14:55 [stderr][+|-r [t]] [-s [p:s]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names]
2022-03-24 11:14:55 [stderr]Use the ``-h'' option to get more help information.
2022-03-24 11:14:55 [stdout]> 현재 구동중인 어플리케이션이 없으므로 종료 안함.
2022-03-24 11:14:56 LifecycleEvent - ApplicationStart
2022-03-24 11:14:56 Script - start.sh
2022-03-24 11:14:56 [stderr]/opt/codedeploy-agent/deployment-root/xxx/yyy/deployment-archive/start.sh: line 8: soucre: command not found
2022-03-24 11:14:56 [stdout]> build file copy
2022-03-24 11:14:56 [stdout]> cp /home/ec2-user/app/nginx/zip/*.jar /home/ec2-user/app/nginx/
2022-03-24 11:14:56 [stderr]cp: cannot stat ‘/home/ec2-user/app/nginx/zip/*.jar’: No such file or directory
2022-03-24 11:14:56 [stdout]> new application deploy!
2022-03-24 11:14:56 [stdout]>JAR NAME : /home/ec2-user/app/nginx/ReFacDiabetesDiary-1.1.9-SNAPSHOT.jar
2022-03-24 11:14:56 [stdout]>/home/ec2-user/app/nginx/ReFacDiabetesDiary-1.1.9-SNAPSHOT.jar 에 실행권한 추가
2022-03-24 11:14:56 [stdout]>/home/ec2-user/app/nginx/ReFacDiabetesDiary-1.1.9-SNAPSHOT.jar 실행
2022-03-24 11:14:56 [stderr]/opt/codedeploy-agent/deployment-root/xxx/yyy/deployment-archive/start.sh: line 26: find_idle_profile: command not found
2022-03-24 11:14:56 [stdout]> 에서 실행!
2022-03-24 11:14:57 LifecycleEvent - ValidateService
2022-03-24 11:14:57 Script - health.sh
발견한 error는 command not found
. 그런데 자세히 살펴보니 soucre
로 되어 있다. source
로 해야하는데 오타다..
이번엔 stop.sh에서 문제가 생기는데, 문제는 로그가 안나온다.
LifecycleEvent - AfterInstall
Script - stop.sh
[stderr]
원인이 되는 appspec.yml은 다음과 같다.
hooks:
# stop spring boot application running
AfterInstall:
- location: stop.sh
timeout: 60
runas: ec2-user
# lunch new spring boot application
ApplicationStart:
- location: start.sh
timeout: 60
runas: ec2-user
# check health of new spring boot application
ValidateService:
- location: health.sh
timeout: 60
runas: ec2-user
timeout 제한이 60이라서 너무 짧은 것이 원인이다. 따라서 해결책은 제한 시간을 180초로 늘리는 것이다.
hooks:
# stop spring boot application running
AfterInstall:
- location: stop.sh
timeout: 180
runas: ec2-user
# lunch new spring boot application
ApplicationStart:
- location: start.sh
timeout: 180
runas: ec2-user
# check health of new spring boot application
ValidateService:
- location: health.sh
timeout: 180
runas: ec2-user
2022 3 24 기준 운영되는 앱은 기존 deploy.sh의 8084 포트에 띄워진 것이다. 8085에 띄워진 것은 현재 실험중.
참고로 포트 확인 명령어는 sudo netstat -tnlp
8086 띄워지나 시도해봤는데, profile.sh: line 17: [: ==: unary operator expected
라는 에러 발생.
$로 시작하는 변수에 ""로 묶었더니 해결함.
4:48 기준 nginx로 두개 포트 운영 성공. 단, https 노출은 이전 포트 그대로.
profile.sh, start.sh, stop.sh, health.sh, swith.sh 등을 추가 및 ec2에 Nginx 재설치 했다. 3-24 11시 4분 기준 s3 및 code deploy까지 전달이 된다. 단, code deploy에서 다음과 같은 에러가 발생한다.
Script at specified location: health.sh failed to complete in 60 seconds