<?php
declare(strict_types=1);

function isBotRunning(): bool {
    $output = [];
    exec("ps aux | grep 'node index.js' | grep -v grep", $output);
    return !empty($output);
}

if (isBotRunning()) {
    http_response_code(200);
    echo "Bot is ONLINE";
} else {
    // Optionally try to restart it? No, just report status
    http_response_code(503);
    echo "Bot is OFFLINE";
}
