diff --git a/ProcessMaker/Application.php b/ProcessMaker/Application.php index 87f85281df..5cea34ac9a 100644 --- a/ProcessMaker/Application.php +++ b/ProcessMaker/Application.php @@ -114,11 +114,4 @@ public function bootstrapWith(array $bootstrappers) return parent::bootstrapWith($bootstrappers); } - - public function reactivateConsoleApp() - { - Container::setInstance($this); - $this->hasBeenBootstrapped = false; - $this->make(Kernel::class)->bootstrap(); - } } diff --git a/ProcessMaker/Console/Commands/HorizonListen.php b/ProcessMaker/Console/Commands/HorizonListen.php new file mode 100644 index 0000000000..a3f3dd47b1 --- /dev/null +++ b/ProcessMaker/Console/Commands/HorizonListen.php @@ -0,0 +1,51 @@ +app->instance('tenant-resolved', false); + + $this->app->when(HorizonListen::class)->needs(Listener::class)->give(function ($app) { + return new Listener(base_path()); + }); + + if (config('app.multitenancy')) { + WorkerCommandString::$command = 'exec @php artisan horizon:listen'; + SystemProcessCounter::$command = 'horizon:listen'; + } } /** @@ -261,13 +271,10 @@ private static function bootstrapTenantApp(JobProcessing|JobRetryRequested $even // Create a new tenant app instance $_SERVER['TENANT'] = $tenantId; - if (!isset(self::$tenantAppContainers[$tenantId])) { - self::$tenantAppContainers[$tenantId] = require base_path('bootstrap/app.php'); - } - self::$tenantAppContainers[$tenantId]->reactivateConsoleApp(); - - // Change the job's app service container to the tenant app - $event->job->getRedisQueue()->setContainer(self::$tenantAppContainers[$tenantId]); + $app = require base_path('bootstrap/app.php'); + $app->make(\ProcessMaker\Console\Kernel::class)->bootstrap(); + \Illuminate\Container\Container::setInstance($app); + $event->job->getRedisQueue()->setContainer($app); } }