feat: concurrent builds / server
This commit is contained in:
		
							parent
							
								
									238337fecb
								
							
						
					
					
						commit
						01f7b07fa3
					
				| @ -220,7 +220,6 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted | |||||||
|             $this->build_server = $this->server; |             $this->build_server = $this->server; | ||||||
|             $this->original_server = $this->server; |             $this->original_server = $this->server; | ||||||
|         } |         } | ||||||
|         ray($this->build_server); |  | ||||||
|         try { |         try { | ||||||
|             if ($this->restart_only && $this->application->build_pack !== 'dockerimage') { |             if ($this->restart_only && $this->application->build_pack !== 'dockerimage') { | ||||||
|                 $this->just_restart(); |                 $this->just_restart(); | ||||||
| @ -311,7 +310,6 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted | |||||||
|     } |     } | ||||||
|     private function push_to_docker_registry($forceFail = false) |     private function push_to_docker_registry($forceFail = false) | ||||||
|     { |     { | ||||||
|         ray((str($this->saved_outputs->get('local_image_found'))->isNotEmpty() && !$this->application->isConfigurationChanged())); |  | ||||||
|         if ( |         if ( | ||||||
|             $this->application->docker_registry_image_name && |             $this->application->docker_registry_image_name && | ||||||
|             $this->application->build_pack !== 'dockerimage' && |             $this->application->build_pack !== 'dockerimage' && | ||||||
|  | |||||||
| @ -27,6 +27,7 @@ class Form extends Component | |||||||
|         'server.settings.is_swarm_manager' => 'required|boolean', |         'server.settings.is_swarm_manager' => 'required|boolean', | ||||||
|         'server.settings.is_swarm_worker' => 'required|boolean', |         'server.settings.is_swarm_worker' => 'required|boolean', | ||||||
|         'server.settings.is_build_server' => 'required|boolean', |         'server.settings.is_build_server' => 'required|boolean', | ||||||
|  |         'server.settings.concurrent_builds' => 'required|integer', | ||||||
|         'wildcard_domain' => 'nullable|url', |         'wildcard_domain' => 'nullable|url', | ||||||
|     ]; |     ]; | ||||||
|     protected $validationAttributes = [ |     protected $validationAttributes = [ | ||||||
| @ -40,6 +41,7 @@ class Form extends Component | |||||||
|         'server.settings.is_swarm_manager' => 'Swarm Manager', |         'server.settings.is_swarm_manager' => 'Swarm Manager', | ||||||
|         'server.settings.is_swarm_worker' => 'Swarm Worker', |         'server.settings.is_swarm_worker' => 'Swarm Worker', | ||||||
|         'server.settings.is_build_server' => 'Build Server', |         'server.settings.is_build_server' => 'Build Server', | ||||||
|  |         'server.settings.concurrent_builds' => 'Concurrent Builds', | ||||||
|     ]; |     ]; | ||||||
| 
 | 
 | ||||||
|     public function mount() |     public function mount() | ||||||
|  | |||||||
| @ -24,8 +24,11 @@ function queue_application_deployment(int $application_id, string $deployment_uu | |||||||
|         'commit' => $commit, |         'commit' => $commit, | ||||||
|         'git_type' => $git_type |         'git_type' => $git_type | ||||||
|     ]); |     ]); | ||||||
|     $queued_deployments = ApplicationDeploymentQueue::where('application_id', $application_id)->where('status', 'queued')->get()->sortByDesc('created_at'); |     $server = Application::find($application_id)->destination->server; | ||||||
|     $running_deployments = ApplicationDeploymentQueue::where('application_id', $application_id)->where('status', 'in_progress')->get()->sortByDesc('created_at'); |     $deployments = ApplicationDeploymentQueue::where('application_id', $application_id); | ||||||
|  |     $queued_deployments = $deployments->where('status', 'queued')->get()->sortByDesc('created_at'); | ||||||
|  |     $running_deployments = $deployments->where('status', 'in_progress')->get()->sortByDesc('created_at'); | ||||||
|  |     $all_deployments = $deployments->where('status', 'queued')->orWhere('status', 'in_progress')->get(); | ||||||
|     ray('Q:' . $queued_deployments->count() . 'R:' . $running_deployments->count() . '| Queuing deployment: ' . $deployment_uuid . ' of applicationID: ' . $application_id . ' pull request: ' . $pull_request_id . ' with commit: ' . $commit . ' and is it forced: ' . $force_rebuild); |     ray('Q:' . $queued_deployments->count() . 'R:' . $running_deployments->count() . '| Queuing deployment: ' . $deployment_uuid . ' of applicationID: ' . $application_id . ' pull request: ' . $pull_request_id . ' with commit: ' . $commit . ' and is it forced: ' . $force_rebuild); | ||||||
|     if ($queued_deployments->count() > 1) { |     if ($queued_deployments->count() > 1) { | ||||||
|         $queued_deployments = $queued_deployments->skip(1); |         $queued_deployments = $queued_deployments->skip(1); | ||||||
| @ -37,6 +40,9 @@ function queue_application_deployment(int $application_id, string $deployment_uu | |||||||
|     if ($running_deployments->count() > 0) { |     if ($running_deployments->count() > 0) { | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  |     if ($all_deployments->count() >= $server->settings->concurrent_builds) { | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|     if ($is_new_deployment) { |     if ($is_new_deployment) { | ||||||
|         dispatch(new ApplicationDeploymentNewJob( |         dispatch(new ApplicationDeploymentNewJob( | ||||||
|             deployment: $deployment, |             deployment: $deployment, | ||||||
| @ -51,7 +57,8 @@ function queue_application_deployment(int $application_id, string $deployment_uu | |||||||
| 
 | 
 | ||||||
| function queue_next_deployment(Application $application, bool $isNew = false) | function queue_next_deployment(Application $application, bool $isNew = false) | ||||||
| { | { | ||||||
|     $next_found = ApplicationDeploymentQueue::where('application_id', $application->id)->where('status', 'queued')->first(); |     $next_found = ApplicationDeploymentQueue::where('status', 'queued')->get()->sortByDesc('created_at')->first(); | ||||||
|  |     ray('Next found: ' . $next_found); | ||||||
|     if ($next_found) { |     if ($next_found) { | ||||||
|         if ($isNew) { |         if ($isNew) { | ||||||
|             dispatch(new ApplicationDeploymentNewJob( |             dispatch(new ApplicationDeploymentNewJob( | ||||||
|  | |||||||
| @ -0,0 +1,28 @@ | |||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | use Illuminate\Database\Migrations\Migration; | ||||||
|  | use Illuminate\Database\Schema\Blueprint; | ||||||
|  | use Illuminate\Support\Facades\Schema; | ||||||
|  | 
 | ||||||
|  | return new class extends Migration | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * Run the migrations. | ||||||
|  |      */ | ||||||
|  |     public function up(): void | ||||||
|  |     { | ||||||
|  |         Schema::table('server_settings', function (Blueprint $table) { | ||||||
|  |             $table->integer('concurrent_builds')->default(3); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Reverse the migrations. | ||||||
|  |      */ | ||||||
|  |     public function down(): void | ||||||
|  |     { | ||||||
|  |         Schema::table('server_settings', function (Blueprint $table) { | ||||||
|  |             $table->dropColumn('concurrent_builds'); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  | }; | ||||||
| @ -86,8 +86,12 @@ | |||||||
| 
 | 
 | ||||||
|         @if ($server->isFunctional()) |         @if ($server->isFunctional()) | ||||||
|             <h3 class="py-4">Settings</h3> |             <h3 class="py-4">Settings</h3> | ||||||
|             <x-forms.input id="cleanup_after_percentage" label="Disk Cleanup threshold (%)" required |             <div class="flex gap-2"> | ||||||
|  |             <x-forms.input id="cleanup_after_percentage" label="Disk cleanup threshold (%)" required | ||||||
|                 helper="Disk cleanup job will be executed if disk usage is more than this number." /> |                 helper="Disk cleanup job will be executed if disk usage is more than this number." /> | ||||||
|  |             <x-forms.input id="server.settings.concurrent_builds" label="Number of concurrent builds" required | ||||||
|  |                 helper="You can define how many concurrent builds processes / deployments should run at the same time." /> | ||||||
|  |             </div> | ||||||
|         @endif |         @endif | ||||||
|     </form> |     </form> | ||||||
| </div> | </div> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user