Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions appspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ permissions:
group: ec2-user

hooks:
BeforeInstall:
- location: scripts/pre_install.sh
timeout: 120
runas: ec2-user
AfterInstall:
- location: scripts/stop.sh
timeout: 60
Expand Down
20 changes: 0 additions & 20 deletions scripts/pre_install.sh

This file was deleted.

16 changes: 16 additions & 0 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
#!/usr/bin/env bash

PROJECT_ROOT="/home/ec2-user/app"

Comment on lines 1 to +4
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

set -euo pipefail 옵션으로 스크립트 안정성을 높이세요

에러 발생 시 즉시 종료(-e), 미정의 변수 사용 시 실패(-u), 파이프라인 오류 감지(-o pipefail)를 설정하지 않으면, cp·docker-compose 등의 실패가 그대로 넘어가서 배포가 불안정해질 수 있습니다. #!/usr/bin/env bash 바로 아래에 다음을 추가하는 것을 권장합니다.

 #!/usr/bin/env bash
+set -euo pipefail
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/usr/bin/env bash
PROJECT_ROOT="/home/ec2-user/app"
#!/usr/bin/env bash
set -euo pipefail
PROJECT_ROOT="/home/ec2-user/app"
🤖 Prompt for AI Agents
In scripts/start.sh at the beginning of the file (lines 1 to 4), the script
lacks the 'set -euo pipefail' option which ensures the script exits immediately
on errors, treats unset variables as errors, and detects errors in pipelines. To
fix this, add 'set -euo pipefail' immediately after the shebang line
'#!/usr/bin/env bash' to improve script reliability and error handling.

NEED_RESTART=0
for CONTAINER in pitchain_filebeat pitchain_logstash pitchain_kibana pitchain_elasticsearch; do
if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER}$"; then
echo "$CONTAINER 컨테이너가 실행 중이 아닙니다."
NEED_RESTART=1
fi
done

if [ $NEED_RESTART -eq 1 ]; then
echo "하나 이상의 ELK 컨테이너가 다운되어 있으므로 ELK 및 Filebeat를 재시작합니다."
docker-compose --env-file $PROJECT_ROOT/.env --profile setup -f $PROJECT_ROOT/docker-compose-elk.yml up --build -d
else
echo "모든 ELK 컨테이너가 정상적으로 실행 중입니다."
fi

JAR_FILE="$PROJECT_ROOT/spring-webapp.jar"

APP_LOG="$PROJECT_ROOT/application.log"
Expand Down