fix: 다중 인스턴스 실행 시 Telegram 409 충돌 #180

Closed
opened 2026-02-20 08:51:29 +09:00 by agentson · 0 comments
Collaborator

문제

두 개의 src.main 프로세스가 동시 실행되면 Telegram getUpdates API에서 409 충돌 발생.

관찰된 로그

ERROR: getUpdates API error (status=409): 
{"ok":false,"error_code":409,
"description":"Conflict: terminated by other getUpdates request; 
make sure that only one bot instance is running"}

재현 조건

  • 기존 프로세스(PID 1710309): python3 -m src.main --mode=paper 실행 중
  • 새 프로세스 추가 실행: python3 -m src.main --mode=paper --dashboard
  • 두 프로세스 모두 같은 Telegram bot token으로 polling 시도

영향

  • Telegram 명령어(/status, /positions 등) 응답 불안정
  • 오류 로그 지속 발생

수정 방안

  1. PID 파일 락: 실행 시 /tmp/ouroboros.pid 파일 확인, 이미 실행 중이면 경고 후 종료
  2. Telegram 인스턴스 감지: 409 응답 시 명확한 경고 메시지 출력 + 재시도 백오프 적용
  3. Systemd/프로세스 관리: 단일 인스턴스 보장 문서화
## 문제 두 개의 `src.main` 프로세스가 동시 실행되면 Telegram getUpdates API에서 409 충돌 발생. ## 관찰된 로그 ``` ERROR: getUpdates API error (status=409): {"ok":false,"error_code":409, "description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"} ``` ## 재현 조건 - 기존 프로세스(PID 1710309): `python3 -m src.main --mode=paper` 실행 중 - 새 프로세스 추가 실행: `python3 -m src.main --mode=paper --dashboard` - 두 프로세스 모두 같은 Telegram bot token으로 polling 시도 ## 영향 - Telegram 명령어(/status, /positions 등) 응답 불안정 - 오류 로그 지속 발생 ## 수정 방안 1. **PID 파일 락**: 실행 시 `/tmp/ouroboros.pid` 파일 확인, 이미 실행 중이면 경고 후 종료 2. **Telegram 인스턴스 감지**: 409 응답 시 명확한 경고 메시지 출력 + 재시도 백오프 적용 3. **Systemd/프로세스 관리**: 단일 인스턴스 보장 문서화
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#180