Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions docs/recipe/magento2.md
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,21 @@ Cleanup cache id_prefix env files.
After successful deployment, move the tmp_env.php file to env.php ready for next deployment


### magento\:queue\:consumers\:stop {#magento-queue-consumers-stop}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L596)

Kill running queue consumers.

Kill running queue consumers, so cron starts them again from the new release.
A consumer only stops after `max_messages` messages. Until then, it runs the code of the previous release.
To use this feature, add the following to your deployer scripts:
```php
after('deploy:symlink', 'magento:queue:consumers:stop');
```


### magento\:cron\:stop {#magento-cron-stop}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L595)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L608)

Remove cron from crontab and kill running cron jobs.

Expand All @@ -773,7 +786,7 @@ To use this feature, add the following to your deployer scripts:


### magento\:cron\:install {#magento-cron-install}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L611)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L625)

Install cron in crontab.

Expand All @@ -785,7 +798,7 @@ To use this feature, add the following to your deployer scripts:


### artifact\:prepare {#artifact-prepare}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L617)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L631)

Prepares an artifact on the target server.

Expand All @@ -805,7 +818,7 @@ This task is group task which contains next tasks:


### artifact\:finish {#artifact-finish}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L630)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L644)

Executes the tasks after artifact is released.

Expand All @@ -821,7 +834,7 @@ This task is group task which contains next tasks:


### artifact\:deploy {#artifact-deploy}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L639)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L653)

Actually releases the artifact deployment.

Expand Down
16 changes: 15 additions & 1 deletion recipe/magento2.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,19 @@ function magentoDeployAssetsSplit(string $area): void
run('{{bin/symlink}} {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH . ' {{release_path}}/' . ENV_CONFIG_FILE_PATH);
});

/**
* Kill running queue consumers, so cron starts them again from the new release.
* A consumer only stops after `max_messages` messages. Until then, it runs the code of the previous release.
* To use this feature, add the following to your deployer scripts:
* ```php
* after('deploy:symlink', 'magento:queue:consumers:stop');
* ```
*/
desc('Kill running queue consumers');
task('magento:queue:consumers:stop', function () {
run('pgrep -U "$(id -u)" -f "bin/magento +queue:consumers:start" | xargs -r kill');
});

/**
* Remove cron from crontab and kill running cron jobs
* To use this feature, add the following to your deployer scripts:
Expand All @@ -597,7 +610,8 @@ function magentoDeployAssetsSplit(string $area): void
run('{{bin/php}} {{previous_release}}/{{magento_dir}}/bin/magento cron:remove');
}

run('pgrep -U "$(id -u)" -f "bin/magento +(cron:run|queue:consumers:start)" | xargs -r kill');
run('pgrep -U "$(id -u)" -f "bin/magento +cron:run" | xargs -r kill');
invoke('magento:queue:consumers:stop');
});

/**
Expand Down
Loading