forked from urvishpatelce/lxd-app
fix
This commit is contained in:
5
add-container.php
Normal file
5
add-container.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
if (count($argv) !== 3) return;
|
||||||
|
$config = json_decode(file_get_contents(__DIR__ . '/api/config.json'), true);
|
||||||
|
$config[$argv[1]] = $argv[2];
|
||||||
|
file_put_contents(__DIR__ . '/api/config.json', json_encode($config));
|
||||||
@ -27,7 +27,6 @@ $lxd = new LxdService();
|
|||||||
|
|
||||||
// === Helper URLs ===
|
// === Helper URLs ===
|
||||||
$redirectBase = parseUrl("$host/app");
|
$redirectBase = parseUrl("$host/app");
|
||||||
$waitingPage = parseUrl("$host/app/waiting?name=$container&redirect=" . urlencode(getFullUrl()));
|
|
||||||
// === If container is missing or invalid ===
|
// === If container is missing or invalid ===
|
||||||
if (!$container || !$lxd->containerExists($container)) {
|
if (!$container || !$lxd->containerExists($container)) {
|
||||||
redirect($redirectBase);
|
redirect($redirectBase);
|
||||||
@ -44,8 +43,8 @@ if ($state !== 'Running') {
|
|||||||
$nginx = $lxd->getContainerServiceStatus($container, 'nginx');
|
$nginx = $lxd->getContainerServiceStatus($container, 'nginx');
|
||||||
$mysql = $lxd->getContainerServiceStatus($container, 'mariadb');
|
$mysql = $lxd->getContainerServiceStatus($container, 'mariadb');
|
||||||
|
|
||||||
if (!$ip || $nginx !== 'active' || $mysql !== 'active') {
|
if ($nginx !== 'active' || $mysql !== 'active') {
|
||||||
redirect($waitingPage);
|
redirect($redirectBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Proxy to container ===
|
// === Proxy to container ===
|
||||||
|
|||||||
Reference in New Issue
Block a user