From 96e25acac8d7fa1789a9302b5e96ab287a4ea819 Mon Sep 17 00:00:00 2001 From: Micha Date: Mon, 16 Dec 2024 11:26:35 +0100 Subject: [PATCH] Add info for messenger stop --- .../deployments/deployment-with-deployer.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/guides/hosting/installation-updates/deployments/deployment-with-deployer.md b/guides/hosting/installation-updates/deployments/deployment-with-deployer.md index ffe7f72e1..1dec23484 100644 --- a/guides/hosting/installation-updates/deployments/deployment-with-deployer.md +++ b/guides/hosting/installation-updates/deployments/deployment-with-deployer.md @@ -157,6 +157,18 @@ After all the steps are done, Deployer will switch the symlinks destination to t This task is defined in the `deploy:symlink` default job in the [`deploy.php`](deployment-with-deployer#deploy-php). +### 8. Stop workers (optional) + +In a production environment, you often run workers in the background. Before deploying a new version, you should stop the workers to prevent them from processing outdated data. + +```php +task('messenger:stop', function () { + if (has('previous_release')) { + run('{{bin/php}} {{previous_release}}/bin/console messenger:stop-workers'); + } +})->desc('Stop workers'); +``` + ## Deployer output This is the output of `dep deploy env=prod`: @@ -360,6 +372,12 @@ task('sw:health_checks', static function () { run('cd {{release_path}} && bin/console system:check --context=pre_rollout'); }); +task('messenger:stop-workers', function () { + if (has('previous_release')) { + run('{{bin/php}} {{previous_release}}/bin/console messenger:stop-workers'); + } +})->desc('Stop workers'); + desc('Deploys your project'); task('deploy', [ 'deploy:prepare', @@ -384,4 +402,5 @@ task('deploy:update_code')->setCallback(static function () { after('deploy:failed', 'deploy:unlock'); after('deploy:symlink', 'cachetool:clear:opcache'); +after('deploy:symlink', 'messenger:stop-workers'); ```