fix(discord-bridge): director de lucru dedicat + log nedublat
- DEFAULT_CWD trece de la /workspace la /workspace/claude-agent, un spatiu cu git propriu, ca fisierele facute din Discord sa aiba istoric separat de proiectele reale. `!cd <cale>` ramane disponibil oriunde in /workspace, deci decizia din plan (fara allowlist de proiecte) nu se schimba. - setup_logging: sub systemd unitul redirecteaza deja stdout in bot.log (StandardOutput=append:), iar FileHandler-ul scria fiecare linie a doua oara in acelasi fisier. FileHandler ramane doar la rulare manuala. Verificat in productie: bot conectat, un tur real incheiat curat (inflight null, cost $0.0742 contabilizat), restart fara orfani. Suita: 275 passed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B29CApsP1JkSdjYaGaHpE7
This commit is contained in:
@@ -480,7 +480,7 @@ class Bridge:
|
||||
"```",
|
||||
f"fir : {thread_id}",
|
||||
f"sesiune : {(proc.sid if proc is not None else None) or rec.get('sid') or '(noua)'}",
|
||||
f"director : {rec.get('cwd') or config.get('DEFAULT_CWD', '/workspace')}",
|
||||
f"director : {rec.get('cwd') or config.get('DEFAULT_CWD', '/workspace/claude-agent')}",
|
||||
f"model : {model}",
|
||||
f"proces : {'viu' if alive else 'oprit'}"
|
||||
+ (f" pid={pid} rss={rss_mb(pid)} MB" if alive and pid else ""),
|
||||
@@ -528,7 +528,7 @@ class Bridge:
|
||||
channel = message.channel
|
||||
rec = self.store.thread(tid)
|
||||
model = rec.get("model") or default_model()
|
||||
cwd = rec.get("cwd") or config.get("DEFAULT_CWD", "/workspace")
|
||||
cwd = rec.get("cwd") or config.get("DEFAULT_CWD", "/workspace/claude-agent")
|
||||
turn_id = runner_mod.new_turn_id()
|
||||
|
||||
try:
|
||||
@@ -676,8 +676,13 @@ def make_client(bridge: Bridge | None = None): # pragma: no cover - are nevoie
|
||||
def setup_logging() -> None: # pragma: no cover
|
||||
config.ensure_dirs()
|
||||
handlers: list[logging.Handler] = [logging.StreamHandler()]
|
||||
with contextlib.suppress(OSError):
|
||||
handlers.append(logging.FileHandler(pathlib.Path(config.LOG_DIR) / "bot.log"))
|
||||
# Sub systemd, unitul redirecteaza deja stdout/stderr in bot.log
|
||||
# (`StandardOutput=append:`). Un FileHandler peste asta ar scrie fiecare
|
||||
# linie de doua ori in acelasi fisier. La rulare manuala nu exista
|
||||
# redirectare, deci acolo tinem FileHandler-ul.
|
||||
if not os.environ.get("INVOCATION_ID"):
|
||||
with contextlib.suppress(OSError):
|
||||
handlers.append(logging.FileHandler(pathlib.Path(config.LOG_DIR) / "bot.log"))
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
||||
|
||||
@@ -30,7 +30,7 @@ DEFAULTS: dict[str, str] = {
|
||||
"IDLE_REAP_S": "1200",
|
||||
"RATE_PER_USER_PER_MIN": "10",
|
||||
"CLAUDE_BIN": "claude",
|
||||
"DEFAULT_CWD": "/workspace",
|
||||
"DEFAULT_CWD": "/workspace/claude-agent",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,4 +48,7 @@ CLAUDE_DISCORD_APPROVAL_TIMEOUT=300
|
||||
ALERT_RECIPIENT=root
|
||||
|
||||
# --- Directorul de lucru implicit -----------------------------------------
|
||||
DEFAULT_CWD=/workspace
|
||||
# Directorul in care porneste un fir nou. Spatiu dedicat, cu git propriu, ca ce se
|
||||
# face din Discord sa aiba istoric separat de proiectele reale. `!cd <cale>` il
|
||||
# schimba per fir, oriunde in /workspace.
|
||||
DEFAULT_CWD=/workspace/claude-agent
|
||||
|
||||
Reference in New Issue
Block a user