docs: 리눅스 기준 접속 방법 안내 및 환경 변수 기반 포트 설정 기능 추가

This commit is contained in:
leeyj
2026-04-20 00:40:50 +09:00
parent ff9d75c26f
commit 379f7eb0c4
4 changed files with 73 additions and 5 deletions
+5
View File
@@ -19,3 +19,8 @@ GEMINI_MODEL=gemini-1.5-flash
# API Integration (Optional) # API Integration (Optional)
# For Obsidian Plugin or external tools # For Obsidian Plugin or external tools
OBSIDIAN_API_TOKEN=your_secret_token_here OBSIDIAN_API_TOKEN=your_secret_token_here
# Server Configuration (Optional)
# Default ports: Windows 5050, Linux 5093
PORT=5093
DEBUG=False
+29
View File
@@ -99,6 +99,21 @@ cp .env.example .env
python brain.py python brain.py
``` ```
## 🌐 접속 방법
서버가 실행되면 브라우저를 통해 다음 주소로 접속할 수 있습니다:
- **로컬 접속 (동일 PC)**: `http://localhost:5093`
- **외부 접속 (타 기기/모바일)**: `http://<서버 IP>:5093`
> [!TIP]
> **포트 설정 변경**:
> 기본 포트(윈도우: 5050, 리눅스: 5093) 외의 다른 포트를 사용하려면 `.env` 파일에서 `PORT=원하는포트` 설정을 추가하세요.
> [!TIP]
> **리눅스에서 서버 IP 확인하기**:
> 터미널에서 `hostname -I` 명령어를 입력하면 현재 서버의 내부 IP 주소를 확인할 수 있습니다.
*`.env` 파일에서 관리자 아이디와 비밀번호를 꼭 수정하고, 필요한 경우에만 `GEMINI_API_KEY`를 등록하세요.* *`.env` 파일에서 관리자 아이디와 비밀번호를 꼭 수정하고, 필요한 경우에만 `GEMINI_API_KEY`를 등록하세요.*
--- ---
@@ -170,6 +185,20 @@ We provide a security model where user data is practically undecipherable. Built
2. Create your `.env` from `.env.example` and update your master credentials. 2. Create your `.env` from `.env.example` and update your master credentials.
3. Launch the server: `python brain.py` (Default port: 5050 on Windows, 5093 on Linux). 3. Launch the server: `python brain.py` (Default port: 5050 on Windows, 5093 on Linux).
### 🌐 How to Access
Once the server is running, you can access it via your web browser:
- **Local Access**: `http://localhost:5093`
- **Remote Access (Mobile/Other PCs)**: `http://<Server IP>:5093`
> [!TIP]
> **Changing the Port**:
> To use a port other than the default (Windows: 5050, Linux: 5093), add `PORT=your_port` to your `.env` file.
> [!TIP]
> **Check IP on Linux**:
> Run `hostname -I` in the terminal to find your server's internal IP address.
--- ---
<div align="center"> <div align="center">
<p>Developed with ❤️ for knowledge lovers.</p> <p>Developed with ❤️ for knowledge lovers.</p>
+18 -5
View File
@@ -7,14 +7,27 @@ from app import create_app
app = create_app() app = create_app()
if __name__ == "__main__": if __name__ == "__main__":
# OS 환경에 따른 설정 분기 # 1. OS 환경에 따른 기본값 설정
is_windows = platform.system() == "Windows" is_windows = platform.system() == "Windows"
default_port = 5050 if is_windows else 5093
default_debug = True if is_windows else False
# Windows(개발/디버그): 5050 포트, Linux(운영): 5093 포트 # 2. 환경 변수 우선 적용 (PORT)
port = 5050 if is_windows else 5093 try:
debug_mode = True if is_windows else False env_port = os.getenv("PORT")
port = int(env_port) if env_port else default_port
except (ValueError, TypeError):
port = default_port
# 3. 환경 변수 우선 적용 (DEBUG)
env_debug = os.getenv("DEBUG")
if env_debug is not None:
debug_mode = env_debug.lower() == "true"
else:
debug_mode = default_debug
print(f"📡 {'Windows' if is_windows else 'Linux'} 환경 감지 - Port: {port}, Debug: {debug_mode}") print(f"📡 {'Windows' if is_windows else 'Linux'} 환경 감지")
print(f"⚙️ 설정 적용 - Port: {port}, Debug: {debug_mode}")
# 향후 Linux 서버 구축시 gunicorn / uwsgi 로 구동 권장 # 향후 Linux 서버 구축시 gunicorn / uwsgi 로 구동 권장
app.run(host="0.0.0.0", port=port, debug=debug_mode) app.run(host="0.0.0.0", port=port, debug=debug_mode)
+21
View File
@@ -0,0 +1,21 @@
# 문서 개선: Linux 환경 접속 방법 추가 (README.md)
## 1. 개요 (버그/변경 내용)
- 사용자가 README.md에 서버 실행 방법은 있으나, 실제 접속 경로(URL) 정보가 부족함을 지적함.
- 특히 Linux 환경에서의 접속 포트(5093)와 외부 기기에서의 접속을 위한 IP 확인 방법 안내가 필요함.
## 2. 조치 사항
- `README.md`의 한국어/영어 섹션에 각각 '접속 방법(How to Access)' 항목을 추가함.
- `brain.py` 리팩토링: `.env` 파일의 `PORT``DEBUG` 환경 변수를 우선적으로 읽도록 수정함.
- **로컬 접속 주소**: `http://localhost:5093` (기본값) 안내.
- **외부 접속 주소**: `http://<서버 IP>:5093` (기본값) 안내.
- **포트 커스터마이징**: `.env`에서 사용자가 원하는 포트를 설정할 수 기능 추가 및 `README.md` 가이드 보완.
- **IP 확인 팁**: Linux 터미널 명령 `hostname -I`를 이용한 내부 IP 확인 방법 추가.
## 3. 결과 및 검증
- `README.md` 파일에 해당 내용이 정상적으로 반영됨을 확인.
- `brain.py`의 실제 포트 설정(`5093`)과 일치함.
## 4. 향후 주의 사항
- 서버의 기본 포트를 변경할 경우, `README.md``brain.py`를 함께 업데이트해야 함.
- 운영 환경(Linux)과 개발 환경(Windows)의 포트가 다르므로(5093 vs 5050), 가이드 작성 시 이를 명확히 구분하여 기술해야 함.