Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug: task was ending when signal was received not after was evaluated #205

Merged
merged 7 commits into from
Oct 19, 2023

Conversation

BlueTM
Copy link
Contributor

@BlueTM BlueTM commented Oct 19, 2023

When was receiving a signal "SIGTERM/SIGHUP" the process immediately exist instead of waiting until gearman current task end.
This fix make it to work as was intended: on signal put a flag on true, before get next task if flag is true stop and exit.

Service/GearmanExecute.php Outdated Show resolved Hide resolved
@@ -79,6 +79,16 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
if (extension_loaded('pcntl') && function_exists('pcntl_async_signals')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extension loaded should be enough, no need to check for the function

Command/GearmanJobExecuteCommand.php Outdated Show resolved Hide resolved
if (extension_loaded('pcntl') && function_exists('pcntl_async_signals')) {
pcntl_async_signals(true);

pcntl_signal(SIGTERM, [$this->gearmanExecute, 'handleSystemSignal']);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should register signal handling on the executor itself

@mihaileu mihaileu merged commit 6e117e9 into mmoreram:master Oct 19, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants