Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Able to check one container only.

Andras Bacsai9b26a2a859c0
diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php
index b3432d3ec3..d78e49bf94 100644
--- a/app/Jobs/ContainerStatusJob.php
+++ b/app/Jobs/ContainerStatusJob.php
@@ -20,11 +20,11 @@ class ContainerStatusJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- public function __construct()
- {
- //
+ public function __construct(
+ public string|null $container_id = null,
+ ) {
}
- public function handle(): void
+ protected function checkAllServers()
{
try {
$servers = Server::all()->reject(fn (Server $server) => $server->settings->is_build_server);
@@ -57,4 +57,29 @@ class ContainerStatusJob implements ShouldQueue
Log::error($e->getMessage());
}
}
+ protected function checkContainerStatus()
+ {
+ try {
+ $application = Application::where('uuid', $this->container_id)->firstOrFail();
+ if (!$application) {
+ return;
+ }
+ if ($application->destination->server) {
+ $container = runRemoteCommandSync($application->destination->server, ["docker inspect --format '{{json .State}}' {$this->container_id}"]);
+ $container = formatDockerCmdOutputToJson($container);
+ $application->status = $container[0]['Status'];
+ $application->save();
+ }
+ } catch (\Exception $e) {
+ Log::error($e->getMessage());
+ }
+ }
+ public function handle(): void
+ {
+ if ($this->container_id) {
+ $this->checkContainerStatus();
+ } else {
+ $this->checkAllServers();
+ }
+ }
}