Updated the start/stop server icons; added routes to handle server stop/start

This commit is contained in:
2022-09-24 20:45:37 -04:00
parent b41b246483
commit 5699c9cf6a
5 changed files with 75 additions and 8 deletions

View File

@ -67,3 +67,33 @@ $app->post('/create', function (Request $request, Response $response, $args) {
->withHeader('Location', '/')
->withStatus(302);
});
// server start route
$app->get('/server/{serverName}/start', function (Request $request, Response $response, $args) {
$config = $this->get('config');
$serverDir = join('/', array($config->get('server_directory'), $args['serverName']));
// create server object and start it
$server = new Server($serverDir);
$server->start();
// redirect the user back to the home page
return $response
->withHeader('Location', '/')
->withStatus(302);
})->setName('start');
// server stop route
$app->get('/server/{serverName}/stop', function (Request $request, Response $response, $args) {
$config = $this->get('config');
$serverDir = join('/', array($config->get('server_directory'), $args['serverName']));
// create server object and start it
$server = new Server($serverDir);
$server->stop();
// redirect the user back to the home page
return $response
->withHeader('Location', '/')
->withStatus(302);
})->setName('stop');