diff --git a/.gitignore b/.gitignore index 54068e03b..9d85ddf63 100644 --- a/.gitignore +++ b/.gitignore @@ -21,5 +21,8 @@ yarn-error.log /.bash_history /_volumes +resources/recipes + .lesshst psysh_history +.psql_history diff --git a/app/Actions/RemoteProcess/DispatchRemoteProcess.php b/app/Actions/CoolifyTask/PrepareCoolifyTask.php similarity index 75% rename from app/Actions/RemoteProcess/DispatchRemoteProcess.php rename to app/Actions/CoolifyTask/PrepareCoolifyTask.php index 2d23513ea..d9a3ece2b 100644 --- a/app/Actions/RemoteProcess/DispatchRemoteProcess.php +++ b/app/Actions/CoolifyTask/PrepareCoolifyTask.php @@ -1,16 +1,16 @@ model) { $properties = $remoteProcessArgs->toArray(); @@ -31,7 +31,7 @@ class DispatchRemoteProcess public function __invoke(): Activity { - $job = new ExecuteRemoteProcess($this->activity); + $job = new HandleCoolifyTaskInQueue($this->activity); dispatch($job); $this->activity->refresh(); return $this->activity; diff --git a/app/Actions/RemoteProcess/RunRemoteProcess.php b/app/Actions/CoolifyTask/RunRemoteProcess.php similarity index 99% rename from app/Actions/RemoteProcess/RunRemoteProcess.php rename to app/Actions/CoolifyTask/RunRemoteProcess.php index 41e86b60d..a8c49a7c7 100644 --- a/app/Actions/RemoteProcess/RunRemoteProcess.php +++ b/app/Actions/CoolifyTask/RunRemoteProcess.php @@ -1,6 +1,6 @@ value, + ) { + } +} diff --git a/app/Data/RemoteProcessArgs.php b/app/Data/RemoteProcessArgs.php deleted file mode 100644 index cdf13cac4..000000000 --- a/app/Data/RemoteProcessArgs.php +++ /dev/null @@ -1,24 +0,0 @@ -value, - public string $status = ProcessStatus::HOLDING->value, - public ?Model $model = null, - ) { - } -} diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 1f234cdab..3bb4c2b23 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -93,7 +93,10 @@ class ProjectController extends Controller if (!$application) { return redirect()->route('dashboard'); } - $activity = Activity::where('properties->deployment_uuid', '=', $deployment_uuid)->first(); + $activity = Activity::query() + ->where('properties->type', '=', 'deployment') + ->where('properties->uuid', '=', $deployment_uuid) + ->first(); return view('project.application.deployment', [ 'application' => $application, diff --git a/app/Http/Livewire/Project/Application/PollDeployment.php b/app/Http/Livewire/Project/Application/PollDeployment.php index 148cadf27..c09106afb 100644 --- a/app/Http/Livewire/Project/Application/PollDeployment.php +++ b/app/Http/Livewire/Project/Application/PollDeployment.php @@ -2,6 +2,7 @@ namespace App\Http\Livewire\Project\Application; +use App\Enums\ActivityTypes; use Livewire\Component; use Spatie\Activitylog\Models\Activity; @@ -14,7 +15,9 @@ class PollDeployment extends Component public function polling() { if ( is_null($this->activity) && isset($this->deployment_uuid)) { - $this->activity = Activity::where('properties->deployment_uuid', '=', $this->deployment_uuid) + $this->activity = Activity::query() + ->where('properties->type', '=', ActivityTypes::DEPLOYMENT->value) + ->where('properties->type_uuid', '=', $this->deployment_uuid) ->first(); } else { $this->activity?->refresh(); diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index a55954df3..5924cae3a 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -38,7 +38,7 @@ class ContainerStatusJob implements ShouldQueue $not_found_applications = $applications; $containers = collect(); foreach ($servers as $server) { - $output = runRemoteCommandSync($server, ['docker ps -a -q --format \'{{json .}}\'']); + $output = instantRemoteProcess($server, ['docker ps -a -q --format \'{{json .}}\'']); $containers = $containers->concat(formatDockerCmdOutputToJson($output)); } foreach ($containers as $container) { @@ -67,7 +67,7 @@ class ContainerStatusJob implements ShouldQueue return; } if ($application->destination->server) { - $container = runRemoteCommandSync($application->destination->server, ["docker inspect --format '{{json .State}}' {$this->container_id}"]); + $container = instantRemoteProcess($application->destination->server, ["docker inspect --format '{{json .State}}' {$this->container_id}"]); $container = formatDockerCmdOutputToJson($container); $application->status = $container[0]['Status']; $application->save(); diff --git a/app/Jobs/DeployApplicationJob.php b/app/Jobs/DeployApplicationJob.php index 9a4393f7c..501f45039 100644 --- a/app/Jobs/DeployApplicationJob.php +++ b/app/Jobs/DeployApplicationJob.php @@ -2,8 +2,8 @@ namespace App\Jobs; -use App\Actions\RemoteProcess\RunRemoteProcess; -use App\Data\RemoteProcessArgs; +use App\Actions\CoolifyTask\RunRemoteProcess; +use App\Data\CoolifyTaskArgs; use App\Enums\ActivityTypes; use App\Models\Application; use App\Models\InstanceSettings; @@ -55,14 +55,14 @@ class DeployApplicationJob implements ShouldQueue $private_key_location = savePrivateKeyForServer($server); - $remoteProcessArgs = new RemoteProcessArgs( + $remoteProcessArgs = new CoolifyTaskArgs( server_ip: $server->ip, private_key_location: $private_key_location, - deployment_uuid: $this->deployment_uuid, command: 'overwritten-later', port: $server->port, user: $server->user, type: ActivityTypes::DEPLOYMENT->value, + type_uuid: $this->deployment_uuid, ); $this->activity = activity() diff --git a/app/Jobs/ExecuteRemoteProcess.php b/app/Jobs/HandleCoolifyTaskInQueue.php similarity index 89% rename from app/Jobs/ExecuteRemoteProcess.php rename to app/Jobs/HandleCoolifyTaskInQueue.php index 3915c2d55..d2236027e 100755 --- a/app/Jobs/ExecuteRemoteProcess.php +++ b/app/Jobs/HandleCoolifyTaskInQueue.php @@ -2,7 +2,7 @@ namespace App\Jobs; -use App\Actions\RemoteProcess\RunRemoteProcess; +use App\Actions\CoolifyTask\RunRemoteProcess; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -10,7 +10,7 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Spatie\Activitylog\Models\Activity; -class ExecuteRemoteProcess implements ShouldQueue +class HandleCoolifyTaskInQueue implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 5813a6235..1256de2cb 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use App\Jobs\HandleCoolifyTaskInQueue; use Illuminate\Queue\Events\JobProcessed; use Illuminate\Support\Facades\Process; use Illuminate\Support\Facades\Queue; @@ -31,7 +32,7 @@ class AppServiceProvider extends ServiceProvider { Queue::after(function (JobProcessed $event) { // @TODO: Remove `coolify-builder` container after the remoteProcess job is finishged and remoteProcess->type == `deployment`. - if ($event->job->resolveName() === 'App\Jobs\ExecuteRemoteProcess') { + if ($event->job->resolveName() === HandleCoolifyTaskInQueue::class) { } }); diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php index 36ee4cdac..2ff739570 100644 --- a/bootstrap/helpers.php +++ b/bootstrap/helpers.php @@ -1,8 +1,7 @@ new RemoteProcessArgs( + return resolve(PrepareCoolifyTask::class, [ + 'remoteProcessArgs' => new CoolifyTaskArgs( server_ip: $server->ip, private_key_location: $private_key_location, - deployment_uuid: $deployment_uuid, command: <<port, user: $server->user, - type: $deployment_uuid ? ActivityTypes::DEPLOYMENT->value : ActivityTypes::REMOTE_PROCESS->value, + type: $type_uuid, + type_uuid: $type_uuid, model: $model, ), ])(); @@ -119,8 +118,8 @@ if (!function_exists('formatDockerLabelsToJson')) { })[0]; } } -if (!function_exists('runRemoteCommandSync')) { - function runRemoteCommandSync(Server $server, array $command, $throwError = true) +if (!function_exists('instantRemoteProcess')) { + function instantRemoteProcess(Server $server, array $command, $throwError = true) { $command_string = implode("\n", $command); $private_key_location = savePrivateKeyForServer($server); diff --git a/resources/views/livewire/project/application/poll-deployment.blade.php b/resources/views/livewire/project/application/poll-deployment.blade.php index c48f1e440..53a5987d6 100644 --- a/resources/views/livewire/project/application/poll-deployment.blade.php +++ b/resources/views/livewire/project/application/poll-deployment.blade.php @@ -1,3 +1,6 @@
-
{{ \App\Actions\RemoteProcess\RunRemoteProcess::decodeOutput($activity) }}
+
{{ \App\Actions\CoolifyTask\RunRemoteProcess::decodeOutput($activity) }}
diff --git a/resources/views/livewire/run-command.blade.php b/resources/views/livewire/run-command.blade.php index 085bc9bb7..3953f2fa4 100755 --- a/resources/views/livewire/run-command.blade.php +++ b/resources/views/livewire/run-command.blade.php @@ -1,7 +1,7 @@