Initial commit
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
ENV PYTHONUNBUFFERED=1 PIP_NO_CACHE_DIR=1
|
||||
WORKDIR /app
|
||||
|
||||
COPY pyproject.toml README.md ./
|
||||
COPY us2kr ./us2kr
|
||||
RUN pip install --no-cache-dir . \
|
||||
&& mkdir -p /app/data /app/reports /app/logs
|
||||
|
||||
VOLUME ["/app/data", "/app/reports", "/app/logs"]
|
||||
CMD ["python", "-m", "us2kr.cli", "daemon"]
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>com.us2kr.daemon</string>
|
||||
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/Users/jsahn/US2KR/.venv/bin/python</string>
|
||||
<string>-m</string>
|
||||
<string>us2kr.cli</string>
|
||||
<string>daemon</string>
|
||||
</array>
|
||||
|
||||
<key>WorkingDirectory</key>
|
||||
<string>/Users/jsahn/US2KR</string>
|
||||
|
||||
<key>EnvironmentVariables</key>
|
||||
<dict>
|
||||
<key>PATH</key>
|
||||
<string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin</string>
|
||||
<key>PYTHONUNBUFFERED</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
|
||||
<!-- 프로세스가 죽으면 즉시 재시작, 로그인 시 자동 기동 -->
|
||||
<key>KeepAlive</key>
|
||||
<true/>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
<key>ThrottleInterval</key>
|
||||
<integer>30</integer>
|
||||
|
||||
<key>StandardOutPath</key>
|
||||
<string>/Users/jsahn/US2KR/logs/launchd.out.log</string>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>/Users/jsahn/US2KR/logs/launchd.err.log</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,18 @@
|
||||
# docker compose -f deploy/compose.yaml up -d --build
|
||||
services:
|
||||
us2kr:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: deploy/Dockerfile
|
||||
container_name: us2kr
|
||||
env_file:
|
||||
- ../.env
|
||||
environment:
|
||||
US2KR_DATA_DIR: /app/data
|
||||
US2KR_REPORTS_DIR: /app/reports
|
||||
US2KR_LOG_DIR: /app/logs
|
||||
volumes:
|
||||
- ../data:/app/data
|
||||
- ../reports:/app/reports
|
||||
- ../logs:/app/logs
|
||||
restart: unless-stopped
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# macOS: launchd 사용자 에이전트로 등록/갱신. 실행: bash deploy/install-launchd.sh
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
PLIST_SRC="$ROOT/deploy/com.us2kr.daemon.plist"
|
||||
PLIST_DST="$HOME/Library/LaunchAgents/com.us2kr.daemon.plist"
|
||||
mkdir -p "$ROOT/logs" "$HOME/Library/LaunchAgents"
|
||||
# 프로젝트 경로가 다르면 plist 안의 경로를 현재 위치로 치환
|
||||
sed "s#/Users/jsahn/US2KR#$ROOT#g" "$PLIST_SRC" > "$PLIST_DST"
|
||||
launchctl bootout "gui/$(id -u)/com.us2kr.daemon" 2>/dev/null || true
|
||||
launchctl bootstrap "gui/$(id -u)" "$PLIST_DST"
|
||||
launchctl kickstart -k "gui/$(id -u)/com.us2kr.daemon"
|
||||
echo "installed: $PLIST_DST"
|
||||
echo "status: launchctl print gui/$(id -u)/com.us2kr.daemon | head -20"
|
||||
echo "logs: tail -f $ROOT/logs/us2kr.log"
|
||||
echo "remove: launchctl bootout gui/$(id -u)/com.us2kr.daemon && rm $PLIST_DST"
|
||||
@@ -0,0 +1,26 @@
|
||||
# Linux systemd unit. 설치:
|
||||
# sudo cp deploy/us2kr.service /etc/systemd/system/us2kr.service
|
||||
# sudo systemctl daemon-reload && sudo systemctl enable --now us2kr
|
||||
# journalctl -u us2kr -f
|
||||
[Unit]
|
||||
Description=US2KR - US market close -> Korea market open briefing daemon
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=us2kr
|
||||
WorkingDirectory=/opt/us2kr
|
||||
EnvironmentFile=/opt/us2kr/.env
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
ExecStart=/opt/us2kr/.venv/bin/python -m us2kr.cli daemon
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
# 하드닝
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
ProtectSystem=strict
|
||||
ReadWritePaths=/opt/us2kr/data /opt/us2kr/reports /opt/us2kr/logs
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user