2024-05-08 12:22:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Actions\Server;
|
|
|
|
|
|
|
|
use App\Models\Server;
|
2024-06-10 20:43:34 +00:00
|
|
|
use Lorisleiva\Actions\Concerns\AsAction;
|
2024-05-08 12:22:35 +00:00
|
|
|
|
|
|
|
class StartSentinel
|
|
|
|
{
|
|
|
|
use AsAction;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-05-08 17:19:32 +00:00
|
|
|
public function handle(Server $server, $version = 'latest', bool $restart = false)
|
2024-05-08 12:22:35 +00:00
|
|
|
{
|
2024-05-08 17:19:32 +00:00
|
|
|
if ($restart) {
|
2024-06-18 14:42:42 +00:00
|
|
|
StopSentinel::run($server);
|
2024-05-08 17:19:32 +00:00
|
|
|
}
|
2024-06-18 14:42:42 +00:00
|
|
|
$metrics_history = $server->settings->metrics_history_days;
|
|
|
|
$refresh_rate = $server->settings->metrics_refresh_rate_seconds;
|
|
|
|
$token = $server->settings->metrics_token;
|
2024-05-09 10:22:49 +00:00
|
|
|
instant_remote_process([
|
2024-06-18 14:42:42 +00:00
|
|
|
"docker run --rm --pull always -d -e \"TOKEN={$token}\" -e \"SCHEDULER=true\" -e \"METRICS_HISTORY={$metrics_history}\" -e \"REFRESH_RATE={$refresh_rate}\" --name coolify-sentinel -v /var/run/docker.sock:/var/run/docker.sock -v /data/coolify/metrics:/app/metrics -v /data/coolify/logs:/app/logs --pid host --health-cmd \"curl --fail http://127.0.0.1:8888/api/health || exit 1\" --health-interval 10s --health-retries 3 ghcr.io/coollabsio/sentinel:$version",
|
2024-06-10 20:43:34 +00:00
|
|
|
'chown -R 9999:root /data/coolify/metrics /data/coolify/logs',
|
|
|
|
'chmod -R 700 /data/coolify/metrics /data/coolify/logs',
|
2024-05-09 10:22:49 +00:00
|
|
|
], $server, false);
|
2024-05-08 12:22:35 +00:00
|
|
|
}
|
|
|
|
}
|