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.

fix

Andras Bacsai8677b1d85dbe
diff --git a/.env.production b/.env.production
index 05e553f394..55294fc40a 100644
--- a/.env.production
+++ b/.env.production
@@ -21,3 +21,5 @@ DB_PASSWORD=
QUEUE_CONNECTION=redis
REDIS_HOST=coolify-redis
REDIS_PASSWORD=
+
+CACHE_DRIVER=redis
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index dc98c54783..f6369005a3 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -16,6 +16,8 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule): void
{
+ $schedule->command('horizon:snapshot')->everyFiveMinutes();
+
$schedule->job(new DockerCleanupDanglingImagesJob)->everyFiveMinutes();
$schedule->job(new AutoUpdateJob)->everyFifteenMinutes();
$schedule->job(new ProxyCheckJob)->everyMinute();
diff --git a/app/Http/Livewire/Project/Application/Deploy.php b/app/Http/Livewire/Project/Application/Deploy.php
index cc3df7e8ba..71dc5318ce 100644
--- a/app/Http/Livewire/Project/Application/Deploy.php
+++ b/app/Http/Livewire/Project/Application/Deploy.php
@@ -27,7 +27,7 @@ class Deploy extends Component
$this->parameters = getParameters();
$this->application = Application::where('id', $this->applicationId)->first();
$this->destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first();
- dispatch(new ContainerStatusJob($this->application->uuid));
+ // dispatch(new ContainerStatusJob($this->application->uuid));
}
protected function setDeploymentUuid()
{
diff --git a/app/Jobs/DeployApplicationJob.php b/app/Jobs/DeployApplicationJob.php
index b580500d1b..a683d2b4ae 100644
--- a/app/Jobs/DeployApplicationJob.php
+++ b/app/Jobs/DeployApplicationJob.php
@@ -5,6 +5,7 @@ namespace App\Jobs;
use App\Actions\CoolifyTask\RunRemoteProcess;
use App\Data\CoolifyTaskArgs;
use App\Enums\ActivityTypes;
+use App\Enums\ProcessStatus;
use App\Models\Application;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -18,12 +19,13 @@ use Symfony\Component\Yaml\Yaml;
use Illuminate\Support\Str;
use Spatie\Url\Url;
use Illuminate\Queue\Middleware\WithoutOverlapping;
+use Throwable;
class DeployApplicationJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- protected $application;
+ protected Application $application;
protected $destination;
protected $source;
protected Activity $activity;
@@ -34,15 +36,13 @@ class DeployApplicationJob implements ShouldQueue
protected $env_args;
public static int $batch_counter = 0;
public $timeout = 3600;
+ public $tries = 60;
public function middleware(): array
{
- return [new WithoutOverlapping($this->application_uuid)];
- }
- public function uniqueId(): string
- {
- return $this->application_uuid;
+ return [(new WithoutOverlapping($this->application->uuid))->releaseAfter(10)];
}
+
public function __construct(
public string $deployment_uuid,
public string $application_uuid,
@@ -223,10 +223,26 @@ COPY --from={$this->application->uuid}:{$this->git_commit}-build /app/{$this->ap
Storage::disk('deployments')->put(Str::kebab($this->application->name) . '/docker-compose.yml', $this->docker_compose);
}
$this->executeNow(["docker rm -f {$this->deployment_uuid} >/dev/null 2>&1"], hideFromOutput: true);
- dispatch(new ContainerStatusJob($this->application_uuid));
+ // dispatch(new ContainerStatusJob($this->application_uuid));
}
}
-
+ public function failed(Throwable $exception): void
+ {
+ $outputStack[] = [
+ 'type' => 'out',
+ 'output' => $exception->getMessage(),
+ 'timestamp' => hrtime(true),
+ 'batch' => DeployApplicationJob::$batch_counter,
+ 'order' => 0,
+ ];
+ $this->activity->description = json_encode($outputStack);
+ $this->activity->properties = $this->activity->properties->merge([
+ 'exitCode' => 0,
+ 'status' => ProcessStatus::ERROR->value,
+ ]);
+ $this->activity->save();
+ $this->fail($exception);
+ }
private function execute_in_builder(string $command)
{
return "docker exec {$this->deployment_uuid} bash -c '{$command}'";
diff --git a/app/Jobs/DockerCleanupDanglingImagesJob.php b/app/Jobs/DockerCleanupDanglingImagesJob.php
index 256016330d..f0aeea9f0a 100644
--- a/app/Jobs/DockerCleanupDanglingImagesJob.php
+++ b/app/Jobs/DockerCleanupDanglingImagesJob.php
@@ -14,7 +14,7 @@ use Illuminate\Support\Facades\Log;
class DockerCleanupDanglingImagesJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-
+ public $timeout = 500;
/**
* Create a new job instance.
*/
diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php
index 79e9e140f4..72b8912e8a 100644
--- a/bootstrap/helpers.php
+++ b/bootstrap/helpers.php
@@ -115,7 +115,7 @@ if (!function_exists('generateSshCommand')) {
. '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '
. '-o PasswordAuthentication=no '
. '-o ConnectTimeout=3600 '
- . '-o ServerAliveInterval=60 '
+ . '-o ServerAliveInterval=20 '
. '-o RequestTTY=no '
. '-o LogLevel=ERROR '
. "-p {$port} "
diff --git a/config/horizon.php b/config/horizon.php
index 2561196447..d9f841aa6e 100644
--- a/config/horizon.php
+++ b/config/horizon.php
@@ -180,7 +180,7 @@ return [
*/
'defaults' => [
- 'supervisor-1' => [
+ 's6' => [
'connection' => 'redis',
'queue' => ['default'],
'balance' => 'auto',
@@ -190,25 +190,27 @@ return [
'maxJobs' => 0,
'memory' => 128,
'tries' => 1,
- 'timeout' => 600,
+ 'timeout' => 3600,
'nice' => 0,
],
],
'environments' => [
'production' => [
- 'supervisor-1' => [
+ 's6' => [
+ 'autoScalingStrategy' => 'size',
'maxProcesses' => env('HORIZON_MAX_PROCESSES', 10),
'balanceMaxShift' => env('HORIZON_BALANCE_MAX_SHIFT', 1),
- 'balanceCooldown' => env('HORIZON_BALANCE_COOLDOWN', 3),
+ 'balanceCooldown' => env('HORIZON_BALANCE_COOLDOWN', 1),
],
],
'local' => [
- 'supervisor-1' => [
+ 's6' => [
+ 'autoScalingStrategy' => 'size',
'maxProcesses' => env('HORIZON_MAX_PROCESSES', 10),
'balanceMaxShift' => env('HORIZON_BALANCE_MAX_SHIFT', 1),
- 'balanceCooldown' => env('HORIZON_BALANCE_COOLDOWN', 3),
+ 'balanceCooldown' => env('HORIZON_BALANCE_COOLDOWN', 1),
],
],
],
diff --git a/docker/dev-ssu/etc/s6-overlay/s6-rc.d/queue-worker/run b/docker/dev-ssu/etc/s6-overlay/s6-rc.d/queue-worker/run
index 99e7184e68..0029f96158 100644
--- a/docker/dev-ssu/etc/s6-overlay/s6-rc.d/queue-worker/run
+++ b/docker/dev-ssu/etc/s6-overlay/s6-rc.d/queue-worker/run
@@ -1,2 +1,2 @@
#!/command/execlineb -P
-su - webuser -c "php /var/www/html/artisan queue:listen --timeout=600"
+su - webuser -c "php /var/www/html/artisan queue:listen"
diff --git a/resources/views/livewire/project/application/get-deployments.blade.php b/resources/views/livewire/project/application/get-deployments.blade.php
index 85bd05e676..ac5af3780b 100644
--- a/resources/views/livewire/project/application/get-deployments.blade.php
+++ b/resources/views/livewire/project/application/get-deployments.blade.php
@@ -1,9 +1,10 @@
<a @class([
- 'bg-coolgray-200 p-2 border-l border-dashed border-transparent transition-colors hover:no-underline',
- 'border-warning hover:bg-warning hover:text-black' =>
- $status == 'in_progress' || $status == 'queued',
- 'border-error hover:bg-error' => $status == 'error',
- 'border-success hover:bg-success' => $status == 'finished',
+ 'bg-coolgray-200 p-2 border-l border-dashed transition-colors hover:no-underline',
+ 'border-warning hover:bg-warning hover:text-black' =>
+ $status === 'in_progress',
+ 'border-primary hover:bg-primary' => $status === 'queued',
+ 'border-error hover:bg-error' => $status === 'error',
+ 'border-success hover:bg-success' => $status === 'finished',
]) @if ($status === 'in_progress' || $status === 'queued')
wire:poll.5000ms='polling'
@endif href="{{ url()->current() }}/{{ $deployment_uuid }}" class="hover:no-underline">
diff --git a/scripts/run b/scripts/run
index 44fe4ca7d6..c0a3fc0697 100755
--- a/scripts/run
+++ b/scripts/run
@@ -25,6 +25,9 @@ function sync-bunny {
function queue {
bash vendor/bin/spin exec -u webuser coolify php artisan queue:listen
}
+function horizon {
+ bash vendor/bin/spin exec -u webuser coolify php artisan horizon -vvv
+}
function schedule {
bash vendor/bin/spin exec -u webuser coolify php artisan schedule:work
}
diff --git a/storage/framework/cache/data/.gitignore b/storage/framework/cache/data/.gitignore
deleted file mode 100644
index d6b7ef32c8..0000000000
--- a/storage/framework/cache/data/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*
-!.gitignore