-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
157 lines (134 loc) · 5.38 KB
/
Copy pathjustfile
File metadata and controls
157 lines (134 loc) · 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# SharpLab — task runner
# Install just: winget install Casey.Just
set shell := ["bash", "-c"]
# List available recipes
default:
@just --list
# ── Dev ────────────────────────────────────────────────────────────────────────
# Start everything: Temporal server + worker + odds poller + injury poller + bet resolver + Discord bot
dev:
#!/usr/bin/env bash
trap 'echo "Shutting down..."; kill $(jobs -p) 2>/dev/null' INT TERM EXIT
echo "▶ Starting Temporal server..."
temporal server start-dev &
echo "⏳ Waiting for Temporal to be ready..."
sleep 5
echo "▶ Starting Temporal worker..."
uv run python -m temporal.worker &
sleep 2
echo "▶ Starting NBA odds polling workflow..."
uv run python -m temporal.start_odds_polling nba
echo "▶ Starting MLB odds polling workflow..."
uv run python -m temporal.start_odds_polling mlb
echo "▶ Starting injury polling workflow..."
uv run python -m temporal.start_injury_polling
echo "▶ Starting NBA bet resolution workflow..."
uv run python -m temporal.start_bet_resolution nba
echo "▶ Starting MLB bet resolution workflow..."
uv run python -m temporal.start_bet_resolution mlb
echo "▶ Starting Discord bot..."
uv run python -m bot.main &
echo "✓ All services running. Ctrl+C to stop."
wait
# ── Individual services ────────────────────────────────────────────────────────
# Start the Temporal dev server
temporal:
temporal server start-dev
# Start the Temporal worker
worker:
uv run python -m temporal.worker
# Kick off the odds polling workflow (one-shot — Temporal keeps it running)
poll sport="nba":
uv run python -m temporal.start_odds_polling {{sport}}
# Kick off the injury polling workflow (one-shot — Temporal keeps it running)
injuries:
uv run python -m temporal.start_injury_polling
# Kick off the bet resolution workflow (one-shot — Temporal keeps it running)
resolve sport="nba":
uv run python -m temporal.start_bet_resolution {{sport}}
# Start the Discord bot
bot:
uv run python -m bot.main
# Start the web leaderboard API (dev mode with auto-reload)
web:
uv run uvicorn web.api:app --host 127.0.0.1 --port 8000 --reload
# ── Tests ──────────────────────────────────────────────────────────────────────
# Run unit tests (fast, no Temporal server needed)
test:
uv run pytest tests/test_activities.py -v
# Run all tests (workflow tests will download a Temporal test server on first run)
test-all:
uv run pytest -v -s
# ── Deploy ────────────────────────────────────────────────────────────────────
VPS := "root@87.99.136.82"
DEPLOY_PATH := "/opt/sharplab"
SERVICES := "sharplab-bot sharplab-worker sharplab-web"
# Deploy to VPS: push, pull main, install deps, restart all services
deploy:
#!/usr/bin/env bash
set -euo pipefail
echo "▶ Pushing to GitHub..."
git push
echo "▶ Deploying to VPS..."
ssh {{VPS}} bash -s <<'REMOTE'
set -euo pipefail
cd {{DEPLOY_PATH}}
# Always deploy from main, regardless of current branch state
git fetch origin main
git checkout main --force
git reset --hard origin/main
echo "▶ On commit: $(git log --oneline -1)"
echo "▶ Installing dependencies..."
source venv/bin/activate
pip install -e . -q
echo "▶ Restarting services..."
for svc in {{SERVICES}}; do
systemctl restart "$svc" && echo " ✓ $svc restarted" || echo " ✗ $svc failed"
done
sleep 2
echo "▶ Service status:"
for svc in {{SERVICES}}; do
status=$(systemctl is-active "$svc")
echo " $svc: $status"
done
REMOTE
echo "✓ Deploy complete"
# Deploy bot only (no worker/web restart)
deploy-bot:
#!/usr/bin/env bash
set -euo pipefail
git push
ssh {{VPS}} bash -s <<'REMOTE'
set -euo pipefail
cd {{DEPLOY_PATH}}
git fetch origin main
git checkout main --force
git reset --hard origin/main
source venv/bin/activate
pip install -e . -q
systemctl restart sharplab-bot
echo "✓ Bot restarted on $(git log --oneline -1)"
REMOTE
# Show VPS service status and recent logs
status:
#!/usr/bin/env bash
ssh {{VPS}} bash -s <<'REMOTE'
echo "── Services ──"
for svc in {{SERVICES}}; do
status=$(systemctl is-active "$svc")
echo " $svc: $status"
done
echo ""
echo "── Recent bot logs ──"
journalctl -u sharplab-bot --no-pager -n 15 --since "10 min ago"
echo ""
echo "── Recent web logs ──"
journalctl -u sharplab-web --no-pager -n 15 --since "10 min ago"
REMOTE
# SSH into the VPS
ssh:
ssh {{VPS}}
# ── Misc ───────────────────────────────────────────────────────────────────────
# Install dependencies
install:
uv sync