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

Introduce Resque_Job_PID so a process PID can be obtained. #334

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mateusz
Copy link

@mateusz mateusz commented Mar 30, 2017

echo Resque_Job_PID::get($token);

HOWITWORKS.md Outdated
@@ -101,47 +101,50 @@ How do the workers process the queues?
8. `Resque_Job->fail()` returns control to the worker (still in
`Resque_Worker::work()`) without a value
* Job
1. The job calls `Resque_Worker->perform()` with the `Resque_Job` as its
1. `Resque_Job_PID` is created, registering the PID of the actual process
Copy link
Contributor

Choose a reason for hiding this comment

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

Check your indentation. I think this file uses spaces instead of tabs.

HOWITWORKS.md Outdated
`COMPLETE`, then returns control, with no value, to the worker (again
still in `Resque_Worker::work()`)
19. `Resque_Worker::work()` calls `exit(0)` to terminate the job process
20. `Resque_Job_PID()` is removed, the forked process will terminate soon
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation again here.

README.md Outdated
@@ -193,6 +193,20 @@ or failed, and are then automatically expired. A status can also
forcefully be expired by calling the `stop()` method on a status
class.

### Obtaining woker process PID ###
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo, plus this should probably say "job PID" ("process" is redundant).

*
* @return int PID of the process doing the job (on non-forking OS, PID of the worker, otherwise forked PID).
*/
public function get()
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this class doesn't let you do anything with the PID other than retrieve it, I'd just make this static, drop __construct() and __toString(), and pass the ID as an argument.

@mateusz mateusz force-pushed the pid-monitor branch 2 times, most recently from 814d976 to 15e2aa4 Compare March 31, 2017 01:02
@mateusz
Copy link
Author

mateusz commented Mar 31, 2017

Thanks for prompt review - all fixed, good to review again.


/**
* Remove the PID tracker for the job.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably update the DocBlock, too. ;-)

@mateusz
Copy link
Author

mateusz commented Mar 31, 2017

Ha, missed that. Thanks for catching :-) How about now?

@danhunsaker
Copy link
Contributor

It's an interesting feature for sure. Everything looks good from here, though it'd be nice to have some way to detect whether the PID belongs to the worker itself or not, and modify the return value accordingly...

All said, 👍

@mateusz
Copy link
Author

mateusz commented Apr 2, 2017

Pray, what happens next? :-)

@danhunsaker
Copy link
Contributor

Now we wait for @chrisboulton to have enough time free to properly review the PR himself, give any feedback he might have (if any), and decide whether to merge. This is the part that requires patience, I'm afraid.

@mateusz
Copy link
Author

mateusz commented Apr 2, 2017

Allright. /pulls out his cigar, cognac, and settles on the armchair by the fireplace.

@chrisboulton
Copy link
Owner

Hi! Thanks for the contribution and working through the things @danhunsaker mentioned.

To be honest, this seems to fit a very specific use case, and would be the kind of thing I'd suggest is something that's implemented as a plugin using the appropriate hooks (if there aren't the right ones there, lets fix that), rather than something that should be supported in core functionality?

danhunsaker added a commit to resque/php-resque that referenced this pull request Dec 11, 2018
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