관리자페이지에서 기본환경설정 메뉴 클릭 시 internal 서버에러가 나는 경우가 있습니다.
그런 경우 아래 경로 이동 후 common.py 안의 내용을 수정하면 해결
cd /srv/g6
vi lib/common.py
/get_host_public_ip로 내용 검색
기존 코드
async def get_host_public_ip() -> str:
"""
호스트의 공인 IP 주소를 반환하는 함수
"""
async with httpx.AsyncClient() as client:
try:
response = await client.get('https://httpbin.org/ip')
return response.json()['origin']
except httpx.TimeoutException:
return "IP 정보를 불러오지 못했습니다. 다시 시도해주세요."
아래 내용으로 수정
logger = logging.getLogger(__name__) # 파일 상단에 이미 있으면 또 안 써도 됨
async def get_host_public_ip() -> str:
"""
호스트의 공인 IP 주소를 반환하는 함수.
- httpbin.org 장애/503/JSON 깨짐/타임아웃이 나도 예외 안 터지게 처리.
"""
url = "https://httpbin.org/ip"
try:
async with httpx.AsyncClient(timeout=5.0) as client:
response = await client.get(url)
# 200이 아니면 (503 등) 예외 발생
response.raise_for_status()
try:
data = response.json()
except json.JSONDecodeError as e:
logger.warning(
"get_host_public_ip: invalid JSON from %s: %s (body=%r)",
url, e, response.text[:200],
)
return ""
origin = data.get("origin", "")
if not isinstance(origin, str):
logger.warning(
"get_host_public_ip: missing/invalid 'origin' in response: %r",
data,
)
return ""
return origin
except Exception as e:
# 타임아웃, 503, 연결 오류 등 다 여기로 옴
logger.warning("get_host_public_ip: failed to fetch %s: %s", url, e)
return ""
이후 서비스 재기동
'IT기술' 카테고리의 다른 글
| 그누보드6 회원메일 발송 에러 수정 (0) | 2025.12.11 |
|---|---|
| 그누보드6 검색 시 결과 없음 문제 (0) | 2025.12.11 |
| 그누보드6 구동 시 TypeError 발생 관련 수정 코드 (0) | 2025.11.14 |
| GitHub 커밋&푸쉬 CMD 사용법 (0) | 2023.08.18 |
| JAVA_HOME 환경변수 설정 (0) | 2022.03.24 |