Skip to content

refactor: run.sh 스크립트 구조 개선 및 가상환경 처리 로직 강화#187

Merged
ImTotem merged 1 commit intodevelopfrom
refactor/runsh
Mar 20, 2026
Merged

refactor: run.sh 스크립트 구조 개선 및 가상환경 처리 로직 강화#187
ImTotem merged 1 commit intodevelopfrom
refactor/runsh

Conversation

@ImTotem
Copy link
Copy Markdown
Contributor

@ImTotem ImTotem commented Mar 20, 2026

No description provided.

@ImTotem ImTotem self-assigned this Mar 20, 2026
Copilot AI review requested due to automatic review settings March 20, 2026 14:00
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 20, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dc1fe3ec-328f-455a-baca-0bf5fc91f454

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/runsh
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can disable sequence diagrams in the walkthrough.

Disable the reviews.sequence_diagrams setting to disable sequence diagrams in the walkthrough.

@ImTotem ImTotem merged commit 9b01d11 into develop Mar 20, 2026
5 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

run.sh 실행 스크립트의 디렉터리 기준을 정리하고(스크립트 위치 기준 ROOT_DIR 도입), 가상환경/의존성 설치/실행 전 검증 로직을 강화해 배치 실행의 안정성을 높이려는 PR입니다.

Changes:

  • ROOT_DIR(run.sh 위치) 기준으로 logs/venv/requirements 경로를 재구성
  • python3 존재 여부, venv 생성 결과, requirements 및 대상 .py 파일 존재 여부를 사전 검증
  • venv의 Python으로 pip install 및 스크립트 실행, 실패 시 명확히 종료 처리

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +12 to +22
# 현재 작업 디렉토리를 BASE_DIR로 설정
BASE_DIR="$(pwd)"

# run.sh 위치
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"

while getopts "n:d:h" opt; do
case $opt in
n) FILE_NAME="$OPTARG" ;;
d) BASE_DIR="$OPTARG" ;;
h) usage ;;
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

-d 옵션으로 지정한 BASE_DIR는 파이썬 파일 경로에만 사용되고, 가상환경/requirements/logs는 ROOT_DIR(run.sh 위치) 기준으로 고정되어 있습니다. 현재 usage 안내(“프로젝트의 디렉터리”)와 실제 동작이 달라 혼동될 수 있으니, 도움말 문구를 -d가 의미하는 경로(실행할 .py 파일이 있는 디렉터리)로 명확히 바꾸거나, requirements/venv/logs도 BASE_DIR를 따르도록 일관성 있게 맞춰주세요.

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +43
# 로그 디렉토리
LOG_DIR="$ROOT_DIR/logs"
FULL_LOG_DIR="$LOG_DIR/$FILE_NAME"
LOG_FILE="$FULL_LOG_DIR/$FILE_NAME.out"

# 로그 디렉토리 생성
mkdir -p "$FULL_LOG_DIR"
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

로그 경로가 ROOT_DIR/logs/$FILE_NAME로 고정되어 있어, 같은 FILE_NAME을 서로 다른 -d 디렉터리에서 실행하면 로그가 덮어써지거나 섞일 수 있습니다. BASE_DIR(혹은 그 해시/slug)까지 포함해 로그 디렉터리를 분리하거나, 로그 출력 파일명을 더 유니크하게 만들어 충돌을 방지하는 편이 안전합니다.

Suggested change
# 로그 디렉토리
LOG_DIR="$ROOT_DIR/logs"
FULL_LOG_DIR="$LOG_DIR/$FILE_NAME"
LOG_FILE="$FULL_LOG_DIR/$FILE_NAME.out"
# 로그 디렉토리 생성
mkdir -p "$FULL_LOG_DIR"
# 로그 디렉토리 (BASE_DIR 기반으로 분리하여 충돌 방지)
BASE_HASH="$(printf '%s' "$BASE_DIR" | md5sum | awk '{print $1}')"
LOG_DIR="$ROOT_DIR/logs/$FILE_NAME/$BASE_HASH"
LOG_FILE="$LOG_DIR/$FILE_NAME.out"
# 로그 디렉토리 생성
mkdir -p "$LOG_DIR"

Copilot uses AI. Check for mistakes.
Comment on lines +38 to +41
LOG_DIR="$ROOT_DIR/logs"
FULL_LOG_DIR="$LOG_DIR/$FILE_NAME"
LOG_FILE="$FULL_LOG_DIR/$FILE_NAME.out"

Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

FILE_NAME가 디렉터리/파일 경로에 그대로 결합됩니다(logs/$FILE_NAME, $BASE_DIR/$FILE_NAME.py). -n ../../something 같은 입력으로 logs 디렉터리 밖에 파일을 만들거나 의도치 않은 경로를 읽도록 유도할 수 있습니다. FILE_NAMEbasename 처리하고 허용 문자(예: [A-Za-z0-9_-])만 통과시키는 검증을 추가해 경로 이동을 차단하는 것이 안전합니다.

Copilot uses AI. Check for mistakes.
Comment on lines 60 to 66
# 가상 환경 확인 및 생성
if [ ! -d "$VENV_DIR" ]; then
echo "Python 가상환경이 없습니다!"
echo "가상환경을 생성합니다..."
python3 -m venv $VENV_DIR >> $FULL_LOG_DIR/$FILE_NAME.out 2>&1
if [ ! -x "$VENV_PYTHON" ]; then
echo "Python 가상환경이 없습니다!" >> "$LOG_FILE"
echo "가상환경을 생성합니다..." >> "$LOG_FILE"
"$PYTHON3_BIN" -m venv "$VENV_DIR" >> "$LOG_FILE" 2>&1
fi

Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

myenvROOT_DIR에 공유하고 매 실행마다 동일 venv에 pip install을 수행하면, 서로 다른 배치가 동시에 실행될 때(또는 동일 배치가 중복 실행될 때) venv 생성/패키지 설치가 경합해 실패하거나 환경이 깨질 수 있습니다. 파일 락(flck) 등으로 venv 생성·설치를 직렬화하거나, 배포 단계에서 의존성 설치를 완료하고 런타임에서는 설치를 생략/조건부로 수행하도록 분리하는 방안을 고려해주세요.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants