From 5b7b96867621874b06ec2e2100b5b6ba45e6d6ae Mon Sep 17 00:00:00 2001 From: billz Date: Thu, 7 Mar 2024 18:44:27 +0100 Subject: [PATCH] Fix: rename systemd service, set serviceStatus flag --- includes/restapi.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/restapi.php b/includes/restapi.php index 015c0cb1..7ae0db6f 100644 --- a/includes/restapi.php +++ b/includes/restapi.php @@ -29,21 +29,21 @@ function DisplayRestAPI() } } } elseif (isset($_POST['StartRestAPIservice'])) { - $status->addMessage('Attempting to start raspap-restapi.service', 'info'); - exec('sudo /bin/systemctl start raspap-restapi', $return); + $status->addMessage('Attempting to start restapi.service', 'info'); + exec('sudo /bin/systemctl start restapi.service', $return); foreach ($return as $line) { $status->addMessage($line, 'info'); } } elseif (isset($_POST['StopRestAPIservice'])) { - $status->addMessage('Attempting to stop raspap-restapi.service', 'info'); - exec('sudo /bin/systemctl stop raspap-restapi.service', $return); + $status->addMessage('Attempting to stop restapi.service', 'info'); + exec('sudo /bin/systemctl stop restapi.service', $return); foreach ($return as $line) { $status->addMessage($line, 'info'); } } } - exec('pidof uvicorn | wc -l', $uvicorn); - $serviceStatus = $uvicorn[0] == 0 ? "down" : "up"; + exec("ps aux | grep -v grep | grep uvicorn", $output, $return); + $serviceStatus = !empty($output) ? "up" : "down"; echo renderTemplate("restapi", compact( "status",