Skip to content
Snippets Groups Projects
Commit 776b023b authored by enzosim's avatar enzosim
Browse files

si le serveur marche plus, le kill puis le relancer

parent f2509e95
Branches master
No related tags found
No related merge requests found
......@@ -77,7 +77,7 @@ class WiktionaryManager
} else {
//$time_start = microtime(true); /*Debug*/
$time_start = microtime(true); /*Debug*/
$url = 'http://localhost:5000/search/' . $language . '/' . $language . '/' . $word . '/a_wikstraktor';
$client = HttpClient::create();
......@@ -86,7 +86,8 @@ class WiktionaryManager
// Make the initial request with a timeout
try {
$response = $client->request('GET', $url);
// dump($response->getStatusCode());die();
// dump($response->getStatusCode());
// dump(gettype($result));dump($url);dump(microtime(true)-$time_start);dump($result);die();/*Debug*/
// Check the HTTP status code
if ($response->getStatusCode() === 200) {
......@@ -94,7 +95,8 @@ class WiktionaryManager
$result = $response->getContent();
}
} catch (TransportExceptionInterface $exception) {
if (empty(exec('ps aux | grep "[a]pp.py"'))) {
$processes = exec('ps aux | grep "[a]pp.py"');
if (empty($processes)) {
// Server is down, restart it
exec('nohup /var/www/live-query-wiktextract/venv/bin/python3 /var/www/live-query-wiktextract/src/app.py');
if (!empty(exec('ps aux | grep "[a]pp.py"'))) {
......@@ -105,12 +107,13 @@ class WiktionaryManager
$result = $response->getContent();
}
} else {
throw new \Exception('Server is down');
}
exec('pkill -f app.py');
exec('nohup /var/www/live-query-wiktextract/venv/bin/python3 /var/www/live-query-wiktextract/src/app.py > /dev/null 2>&1 &');
}
}
}
}
//dump(gettype($result));dump($url);dump(microtime(true)-$time_start);dump($result);/*Debug*/
// dump(gettype($result));dump($url);dump(microtime(true)-$time_start);dump($result);/*Debug*/
// Output and error handling
$dataArray = json_decode($result, true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment