Fix reactor startup: auto-create venv, requirements.txt, SETUP button, self-install

- deploy/requirements.txt: explicit pip deps (fastapi, uvicorn, aiomysql, aiohttp, anthropic, trafilatura)
- jarvis-deploy.sh: self-installs to /usr/local/bin/ on every run so updates propagate;
  auto-creates venv and installs packages if missing before restart attempt
- admin/index.php: add SETUP button next to RESTART — runs full setup+start in one click
  (creates venv, installs deps, copies reactor.py, starts it)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X8tDRrQqgLjqXebMCBNcP3
This commit is contained in:
2026-07-01 04:11:12 -05:00
parent dfc92a6791
commit af03a2f2d8
3 changed files with 38 additions and 5 deletions
+18 -1
View File
@@ -552,6 +552,20 @@ if ($action) {
} elseif ($wType === 'daemon' && $wId === 'arc_reactor' && $wAction === 'restart') {
shell_exec('bash -c "mkdir -p /home/jarvis.orbishosting.com/logs; systemctl restart jarvis-arc 2>/dev/null || (pkill -f reactor.py 2>/dev/null; sleep 1; cd /opt/jarvis-arc && source venv/bin/activate && nohup python3 reactor.py >> /home/jarvis.orbishosting.com/logs/arc_reactor.log 2>&1 &)"');
j(['ok'=>true,'msg'=>'Arc Reactor restarting']);
} elseif ($wType === 'daemon' && $wId === 'arc_reactor' && $wAction === 'setup') {
$setupLog = '/home/jarvis.orbishosting.com/logs/arc_reactor.log';
$cmd = 'bash -c "'.
'mkdir -p /opt/jarvis-arc /home/jarvis.orbishosting.com/logs && '.
'cp /var/www/jarvis/deploy/reactor.py /opt/jarvis-arc/reactor.py && '.
'cp /var/www/jarvis/deploy/requirements.txt /opt/jarvis-arc/requirements.txt && '.
'if [ ! -d /opt/jarvis-arc/venv ]; then python3 -m venv /opt/jarvis-arc/venv; fi && '.
'/opt/jarvis-arc/venv/bin/pip install -q -r /opt/jarvis-arc/requirements.txt && '.
'pkill -f reactor.py 2>/dev/null; sleep 1 && '.
'cd /opt/jarvis-arc && source venv/bin/activate && '.
'nohup python3 reactor.py >> '.$setupLog.' 2>&1 &'.
'" >> '.$setupLog.' 2>&1';
shell_exec($cmd);
j(['ok'=>true,'msg'=>'Arc Reactor setup started — check log in ~30s then restart']);
} else { bad('Invalid worker action'); }
break;
case 'arc_status':
@@ -2332,7 +2346,10 @@ async function loadWorkers() {
<td class="ts">jarvis-do :7474</td>
<td>${rdot}${ron?'<span style="color:var(--green)">ONLINE</span>':'<span style="color:var(--red)">OFFLINE</span>'}</td>
<td class="ts">${rinfo}</td>
<td><button onclick="workerAction('daemon','arc_reactor','restart')" style="${wBtn('red')}">&#8635; RESTART</button></td>
<td style="display:flex;gap:4px">
<button onclick="workerAction('daemon','arc_reactor','restart')" style="${wBtn('red')}">&#8635; RESTART</button>
<button onclick="workerAction('daemon','arc_reactor','setup')" style="${wBtn('orange')}">&#9881; SETUP</button>
</td>
</tr>`;
}
async function loadDashboard() {