Skip to content

Commit df13877

Browse files
aaron-jangclaude
andcommitted
readme: 스크립트 실행 + systemd 서비스 등록 방법 추가
- 방법 2: scripts/setup.sh + start/stop/logs 사용법 - 방법 3: systemd 서비스 등록 (재부팅 자동 실행) - 라즈베리파이 libopenblas-dev 설치 안내 추가 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e91b18b commit df13877

1 file changed

Lines changed: 48 additions & 10 deletions

File tree

README.md

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,61 @@ docker compose logs -f
6767
docker compose down
6868
```
6969

70-
### 방법 2: 직접 실행
70+
### 방법 2: 스크립트 실행 (라즈베리파이 / Linux)
7171

7272
```bash
73-
# 1. 패키지 설치
74-
pip install -r requirements.txt
73+
git clone https://github.com/aaron-jang/KIS-API-Python-Trading-Bot-Example.git
74+
cd KIS-API-Python-Trading-Bot-Example
7575

76-
# 2. 환경변수 설정
77-
cp .env.example .env
78-
# .env 파일에 실제 키 입력
76+
# 라즈베리파이의 경우 시스템 라이브러리 필요
77+
sudo apt install -y libopenblas-dev
78+
79+
# 초기 설치 (venv 생성 + 패키지 설치)
80+
./scripts/setup.sh
81+
82+
# .env 편집
83+
vi .env
7984

80-
# 3. 실행
81-
python main.py
85+
# 실행 / 중지 / 로그
86+
./scripts/start.sh
87+
./scripts/stop.sh
88+
./scripts/logs.sh
89+
```
90+
91+
### 방법 3: systemd 서비스 등록 (재부팅 시 자동 실행)
8292

83-
# (서버 백그라운드 실행)
84-
nohup python main.py &
93+
```bash
94+
sudo tee /etc/systemd/system/kis-trading-bot.service << 'EOF'
95+
[Unit]
96+
Description=KIS Trading Bot
97+
After=network-online.target
98+
Wants=network-online.target
99+
100+
[Service]
101+
Type=simple
102+
User=pi
103+
WorkingDirectory=/home/pi/project/kis-api-python
104+
Environment="TZ=Asia/Seoul"
105+
ExecStart=/home/pi/project/kis-api-python/venv/bin/python /home/pi/project/kis-api-python/main.py
106+
Restart=always
107+
RestartSec=10
108+
109+
[Install]
110+
WantedBy=multi-user.target
111+
EOF
112+
113+
sudo systemctl daemon-reload
114+
sudo systemctl enable kis-trading-bot # 부팅 시 자동 시작
115+
sudo systemctl start kis-trading-bot # 지금 시작
116+
117+
# 관리
118+
sudo systemctl status kis-trading-bot # 상태 확인
119+
sudo systemctl restart kis-trading-bot # 재시작
120+
journalctl -u kis-trading-bot -f # 실시간 로그
85121
```
86122

123+
> `User`, `WorkingDirectory`, `ExecStart` 경로는 환경에 맞게 수정하세요.
124+
87125
### 환경 변수 (.env)
88126

89127
```

0 commit comments

Comments
 (0)