move venv to shared (#1291)
This commit is contained in:
+2
-2
@@ -193,7 +193,7 @@ async def on_ready():
|
||||
"""Handle bot startup: write guild report, refresh presence, init caches, and start tasks."""
|
||||
GUILD_TOTAL = len(bot.guilds)
|
||||
|
||||
out_path = STORAGE_DIR / "GUILD_REPORT.txt"
|
||||
out_path = STORAGE_DIR / "SREBOT_GUILDS.txt"
|
||||
with out_path.open("w", encoding="utf-8") as f:
|
||||
f.write(f"We have logged in as {bot.user} in the following Guilds:\n\n")
|
||||
for guild in bot.guilds:
|
||||
@@ -334,7 +334,7 @@ async def _refresh_presence():
|
||||
await bot.change_presence(
|
||||
activity=discord.Activity(
|
||||
type=discord.ActivityType.playing,
|
||||
name=f"Playing War Thunder in {GUILD_TOTAL} servers!"
|
||||
name=f"Playing SRE in {GUILD_TOTAL} servers!"
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Smoke test for BOT/render_recap.py in --mode player.
|
||||
|
||||
Usage:
|
||||
source .venv/bin/activate && python BOT/tests/smoke_player_recap.py
|
||||
source ../SHARED/.venv/bin/activate && python BOT/tests/smoke_player_recap.py
|
||||
"""
|
||||
|
||||
import sqlite3
|
||||
|
||||
@@ -5,7 +5,7 @@ Runs the renderer end-to-end against the live HC storage volume databases
|
||||
and verifies a PNG lands at the --out path.
|
||||
|
||||
Usage:
|
||||
source .venv/bin/activate && python BOT/tests/smoke_recap.py
|
||||
source ../SHARED/.venv/bin/activate && python BOT/tests/smoke_recap.py
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
|
||||
+1
-1
@@ -1957,7 +1957,7 @@ _REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
SQUADRON_RECAP_CACHE_DIR = STORAGE_DIR / "RECAPS" / "squadrons"
|
||||
PLAYER_RECAP_CACHE_DIR = STORAGE_DIR / "RECAPS" / "players"
|
||||
|
||||
_RECAP_PYTHON_BIN = _REPO_ROOT / ".venv" / "bin" / "python"
|
||||
_RECAP_PYTHON_BIN = _REPO_ROOT.parent / "SHARED" / ".venv" / "bin" / "python"
|
||||
_RECAP_SCRIPT = _REPO_ROOT / "BOT" / "render_recap.py"
|
||||
|
||||
RECAP_TTL_SECONDS = 24 * 60 * 60 # in-progress season TTL (matches web)
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
cd BOTS/SREBOT
|
||||
```
|
||||
|
||||
2. **Set up Python virtual environment**
|
||||
2. **Set up the shared Python virtual environment** (used by both SREBOT and TSSBOT)
|
||||
```bash
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
python3 -m venv ../SHARED/.venv
|
||||
source ../SHARED/.venv/bin/activate
|
||||
```
|
||||
|
||||
3. **Install dependencies**
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
pip install -r ../SHARED/requirements.txt
|
||||
```
|
||||
|
||||
4. **Configure environment variables**
|
||||
|
||||
+6
-3
@@ -6,13 +6,16 @@
|
||||
|
||||
const DEPLOY_PATH = __dirname;
|
||||
|
||||
// Both bots share one venv at BOTS/SHARED/.venv (built from SHARED/requirements.txt).
|
||||
const PY_INTERPRETER = `${DEPLOY_PATH}/../SHARED/.venv/bin/python`;
|
||||
|
||||
module.exports = {
|
||||
apps: [
|
||||
// Discord Bot
|
||||
{
|
||||
name: 'srebot',
|
||||
script: 'start_bot.py',
|
||||
interpreter: `${DEPLOY_PATH}/.venv/bin/python`,
|
||||
interpreter: PY_INTERPRETER,
|
||||
cwd: DEPLOY_PATH,
|
||||
instances: 1,
|
||||
autorestart: true,
|
||||
@@ -54,7 +57,7 @@ module.exports = {
|
||||
{
|
||||
name: 'srebot-axbot',
|
||||
script: 'BOT/srebot_external.py',
|
||||
interpreter: `${DEPLOY_PATH}/.venv/bin/python`,
|
||||
interpreter: PY_INTERPRETER,
|
||||
cwd: DEPLOY_PATH,
|
||||
instances: 1,
|
||||
autorestart: true,
|
||||
@@ -74,7 +77,7 @@ module.exports = {
|
||||
{
|
||||
name: 'srebot-webhook',
|
||||
script: 'github_webhook_updater.py',
|
||||
interpreter: `${DEPLOY_PATH}/.venv/bin/python`,
|
||||
interpreter: PY_INTERPRETER,
|
||||
cwd: DEPLOY_PATH,
|
||||
instances: 1,
|
||||
autorestart: true,
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
discord.py>=2.4.0,<3.0.0
|
||||
requests>=2.32.3,<3.0.0
|
||||
beautifulsoup4>=4.12.3,<5.0.0
|
||||
lxml>=5.0.0
|
||||
zstandard
|
||||
lz4==4.3.3
|
||||
aiofiles
|
||||
aiohttp
|
||||
aiohttp-socks
|
||||
websockets>=13.0
|
||||
aiosqlite
|
||||
deepl
|
||||
python-dotenv>=1.0.0
|
||||
flask>=2.0.0
|
||||
Pillow>=10.0.0
|
||||
WtFileUtils
|
||||
dotenv
|
||||
numpy
|
||||
wcwidth
|
||||
fontTools
|
||||
matplotlib
|
||||
@@ -4,7 +4,7 @@ right now. Compare against the local entitlements.db cache.
|
||||
|
||||
Usage (on the server):
|
||||
cd ~/GitHub/SREBOT_MEOW
|
||||
source .venv/bin/activate
|
||||
source ../SHARED/.venv/bin/activate
|
||||
python scripts/diag_entitlements.py
|
||||
|
||||
Targeted guild: 1379510072815779961 (bot owner's max-tier server).
|
||||
|
||||
@@ -8,7 +8,7 @@ mismatch, squadron-name mismatch).
|
||||
|
||||
Usage (on the server):
|
||||
cd ~/SREBOT/SREBOT_MEOW
|
||||
source .venv/bin/activate
|
||||
source ../SHARED/.venv/bin/activate
|
||||
python scripts/diag_meta_points.py 1378960248118841507
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -20,7 +20,7 @@ Run with `--dry-run` first. The script prints exactly what it would do.
|
||||
|
||||
Usage
|
||||
-----
|
||||
source .venv/bin/activate
|
||||
source ../SHARED/.venv/bin/activate
|
||||
python scripts/migrate_clan_id.py --dry-run
|
||||
python scripts/migrate_clan_id.py --apply
|
||||
"""
|
||||
|
||||
+5
-5
@@ -156,7 +156,7 @@ const SQUADRON_RECAP_CACHE_DIR = path.join(STORAGE_ROOT, 'RECAPS', 'squadrons');
|
||||
const PLAYER_RECAP_CACHE_DIR = path.join(STORAGE_ROOT, 'RECAPS', 'players');
|
||||
const RECAP_TTL_MS = 24 * 60 * 60 * 1000; // in-progress season TTL
|
||||
const RECAP_RENDER_TIMEOUT_MS = 30_000;
|
||||
const PYTHON_BIN = path.join(REPO_ROOT, '.venv', 'bin', 'python');
|
||||
const PYTHON_BIN = path.join(REPO_ROOT, '..', 'SHARED', '.venv', 'bin', 'python');
|
||||
const RECAP_SCRIPT = path.join(REPO_ROOT, 'BOT', 'render_recap.py');
|
||||
|
||||
function resolveReplaySessionDir(sessionId) {
|
||||
@@ -1896,7 +1896,7 @@ app.get('/api/match/:sessionId/video', async (req, res) => {
|
||||
_videoRenderCount++;
|
||||
try {
|
||||
await new Promise((resolve, reject) => {
|
||||
const pythonBin = path.join(__dirname, '..', '.venv', 'bin', 'python');
|
||||
const pythonBin = path.join(__dirname, '..', '..', 'SHARED', '.venv', 'bin', 'python');
|
||||
execFile(pythonBin, ['-m', 'BOT.render_replay', replayPath, videoPath], {
|
||||
timeout: 120000,
|
||||
cwd: path.join(__dirname, '..')
|
||||
@@ -1959,7 +1959,7 @@ app.get('/api/match/:sessionId/replay-canvas', async (req, res) => {
|
||||
_canvasRenderCount++;
|
||||
try {
|
||||
await new Promise((resolve, reject) => {
|
||||
const pythonBin = path.join(__dirname, '..', '.venv', 'bin', 'python');
|
||||
const pythonBin = path.join(__dirname, '..', '..', 'SHARED', '.venv', 'bin', 'python');
|
||||
execFile(pythonBin, ['-m', 'BOT.render_replay', replayPath, jsonPath], {
|
||||
timeout: 30000,
|
||||
cwd: path.join(__dirname, '..')
|
||||
@@ -2338,9 +2338,9 @@ app.get('/api/stats', cors(apiCorsOptions), async (req, res) => {
|
||||
return res.json({ ...statsCache, uptime: Math.floor(process.uptime()) });
|
||||
}
|
||||
|
||||
// Guild count from GUILD_REPORT.txt (bot writes one line per guild on startup)
|
||||
// Guild count from SREBOT_GUILDS.txt (bot writes one line per guild on startup)
|
||||
let servers = 0;
|
||||
const reportPath = path.join(STORAGE_ROOT, 'GUILD_REPORT.txt');
|
||||
const reportPath = path.join(STORAGE_ROOT, 'SREBOT_GUILDS.txt');
|
||||
try {
|
||||
const report = fs.readFileSync(reportPath, 'utf8').trim();
|
||||
servers = report ? report.split('\n').length : 0;
|
||||
|
||||
Reference in New Issue
Block a user