forked from hostspaceng/coolify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pull new sentinel image and restart container
- Loading branch information
1 parent
76a5290
commit 1a152a5
Showing
7 changed files
with
76 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use App\Actions\Server\StartSentinel; | ||
use App\Models\Server; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldBeEncrypted; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\Middleware\WithoutOverlapping; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class PullSentinelImageJob implements ShouldQueue, ShouldBeEncrypted | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
public $timeout = 1000; | ||
|
||
public function middleware(): array | ||
{ | ||
return [(new WithoutOverlapping($this->server->uuid))]; | ||
} | ||
|
||
public function uniqueId(): string | ||
{ | ||
return $this->server->uuid; | ||
} | ||
public function __construct(public Server $server) | ||
{ | ||
} | ||
public function handle(): void | ||
{ | ||
try { | ||
$version = get_latest_sentinel_version(); | ||
if (!$version) { | ||
ray('Failed to get latest Sentinel version'); | ||
return; | ||
} | ||
$local_version = instant_remote_process(['docker exec coolify-sentinel sh -c "curl http://127.0.0.1:8888/api/version"'], $this->server, '0.0.0'); | ||
if ($version === $local_version) { | ||
ray('Sentinel image is up to date'); | ||
return; | ||
} | ||
ray('Pulling Sentinel image'); | ||
StartSentinel::run($this->server, $version, true); | ||
} catch (\Throwable $e) { | ||
send_internal_notification('PullSentinelImageJob failed with: ' . $e->getMessage()); | ||
ray($e->getMessage()); | ||
throw $e; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,9 @@ | |
"coolify": { | ||
"v4": { | ||
"version": "4.0.0-beta.277" | ||
}, | ||
"sentinel": { | ||
"version": "0.0.1" | ||
} | ||
} | ||
} | ||
|