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

Proper reaction for SIGTERM and SIGINT #177

Merged
merged 2 commits into from
May 4, 2015

Conversation

igormukhingmailcom
Copy link
Contributor

That at this time compatible with PHP 5.3 and graceful degradation for running on Windows

@Baachi
Copy link
Collaborator

Baachi commented Mar 26, 2015

@ddeboer WDYT?

@igormukhingmailcom
Copy link
Contributor Author

@Baachi Hi. What is your decision?

@ddeboer
Copy link
Owner

ddeboer commented May 3, 2015

@igormukhingmailcom I think this makes sense. Classes have been moved due to a switch to PSR-4, so could you please rebase your PR on master? Thanks!

$this->shouldStop = false;
if (is_callable('pcntl_signal')) {
pcntl_signal(SIGTERM, array($this, 'stop'));
pcntl_signal(SIGINT, array($this, 'stop'));
Copy link
Owner

Choose a reason for hiding this comment

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

If you like, you can use [ ... ] here, as this lib now requires PHP 5.4.

@igormukhingmailcom
Copy link
Contributor Author

Looks like rebased successfully. But I totally unsure if I break all or not. Doing this first time... I've used --force key for pushing changes to my branch pcntl:

igor@toshiba-pc:/var/www/opensource/igormukhingmailcom/data-import$ git push origin pcntl
To [email protected]:igormukhingmailcom/data-import.git
 ! [rejected]        pcntl -> pcntl (non-fast-forward)
error: failed to push some refs to '[email protected]:igormukhingmailcom/data-import.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
igor@toshiba-pc:/var/www/opensource/igormukhingmailcom/data-import$ git push --help
igor@toshiba-pc:/var/www/opensource/igormukhingmailcom/data-import$ git push origin pcntl --force
Counting objects: 28, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 1.04 KiB | 0 bytes/s, done.
Total 8 (delta 6), reused 0 (delta 0)
To [email protected]:igormukhingmailcom/data-import.git
 + c297225...577a1f8 pcntl -> pcntl (forced update)

@ddeboer
Copy link
Owner

ddeboer commented May 4, 2015

You did it right. After rebasing, a force push is always necessary to overwrite the previous commits. As long as you make sure to only force push in your own branches (never to master) you’ll be fine.

Thanks!

ddeboer added a commit that referenced this pull request May 4, 2015
Proper reaction for SIGTERM and SIGINT
@ddeboer ddeboer merged commit a07d322 into ddeboer:master May 4, 2015
@igormukhingmailcom igormukhingmailcom deleted the pcntl branch May 6, 2015 12:33
@sagikazarmark
Copy link
Contributor

I find this PR a little bit odd. Why is it necessary? Killing the process is not enough?

@ddeboer
Copy link
Owner

ddeboer commented May 9, 2015

It is enough to stop the import, but with this PR you can still get the result from a stopped import.

@sagikazarmark
Copy link
Contributor

I see. My other problem is that the PCNTL extension availability is checked through is_callables which is called in every cycle of the loop.

I would add a constant instead:

defined('PCNTL_AVAILABLE') or define('PCNTL_AVAILABLE', extension_loaded('pcntl'));

and check this instead. It is way much faster.

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.

4 participants