From a9ea75db98494a759ddf2003ef73598acada2f70 Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Wed, 1 Jul 2026 03:56:11 -0500 Subject: [PATCH] Fix Arc Reactor restart: use bash for source, add systemd service, fix deploy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The admin panel restart command used shell_exec which runs /bin/sh (dash on Ubuntu) — dash doesn't support 'source', so the venv never activated and the reactor silently never started. - admin/index.php: wrap restart in bash -c so 'source' works; try systemctl first then fall back to nohup - deploy/jarvis-arc.service: add proper systemd unit so reactor auto-starts on boot and auto-restarts on crash - deploy/jarvis-deploy.sh: install+enable service file when it changes; mkdir log dir before restart; fall back to nohup if systemctl not set up yet Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_01X8tDRrQqgLjqXebMCBNcP3 --- deploy/jarvis-arc.service | 17 +++++++++++++++++ deploy/jarvis-deploy.sh | 15 ++++++++++++--- public_html/admin/index.php | 2 +- 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 deploy/jarvis-arc.service diff --git a/deploy/jarvis-arc.service b/deploy/jarvis-arc.service new file mode 100644 index 0000000..dc8054b --- /dev/null +++ b/deploy/jarvis-arc.service @@ -0,0 +1,17 @@ +[Unit] +Description=JARVIS Arc Reactor +After=network-online.target mysql.service +Wants=network-online.target + +[Service] +Type=simple +WorkingDirectory=/opt/jarvis-arc +ExecStart=/opt/jarvis-arc/venv/bin/python3 /opt/jarvis-arc/reactor.py +Restart=always +RestartSec=10 +User=root +StandardOutput=append:/home/jarvis.orbishosting.com/logs/arc_reactor.log +StandardError=append:/home/jarvis.orbishosting.com/logs/arc_reactor.log + +[Install] +WantedBy=multi-user.target diff --git a/deploy/jarvis-deploy.sh b/deploy/jarvis-deploy.sh index 8cda0ca..eb5f936 100755 --- a/deploy/jarvis-deploy.sh +++ b/deploy/jarvis-deploy.sh @@ -80,10 +80,19 @@ while IFS= read -r path; do systemctl reload lsws 2>/dev/null || systemctl restart lsws 2>/dev/null log "OLS reloaded for JARVIS deploy" - # Sync reactor.py to runtime location if it changed - if echo "$CHANGED" | grep -q 'deploy/reactor.py'; then + # Sync reactor.py + service file to runtime location if they changed + if echo "$CHANGED" | grep -q 'deploy/reactor.py\|deploy/jarvis-arc.service'; then + mkdir -p /opt/jarvis-arc cp "$path/deploy/reactor.py" /opt/jarvis-arc/reactor.py - systemctl restart jarvis-arc + if echo "$CHANGED" | grep -q 'deploy/jarvis-arc.service'; then + cp "$path/deploy/jarvis-arc.service" /etc/systemd/system/jarvis-arc.service + systemctl daemon-reload + systemctl enable jarvis-arc + log "Arc Reactor service file installed and enabled" + fi + mkdir -p /home/jarvis.orbishosting.com/logs + systemctl restart jarvis-arc 2>/dev/null || \ + bash -c "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 &" log "Arc Reactor updated and restarted (reactor.py changed)" fi fi diff --git a/public_html/admin/index.php b/public_html/admin/index.php index a440ce7..8941d02 100644 --- a/public_html/admin/index.php +++ b/public_html/admin/index.php @@ -550,7 +550,7 @@ if ($action) { j(['ok'=>true,'msg'=>ucwords(str_replace('_',' ',$wId)).' triggered']); } else { bad('Unknown cron worker'); } } elseif ($wType === 'daemon' && $wId === 'arc_reactor' && $wAction === 'restart') { - shell_exec('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 &'); + 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']); } else { bad('Invalid worker action'); } break;