| Total Complexity | 3 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class Resque_Job_PID |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Create a new PID tracker item for the supplied job ID. |
||
| 13 | * |
||
| 14 | * @param string $id The ID of the job to track the PID of. |
||
| 15 | */ |
||
| 16 | public static function create($id) |
||
| 17 | { |
||
| 18 | Resque::redis()->set('job:' . $id . ':pid', (string)getmypid()); |
||
|
|
|||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Fetch the PID for the process actually executing the job. |
||
| 23 | * |
||
| 24 | * @param string $id The ID of the job to get the PID of. |
||
| 25 | * |
||
| 26 | * @return int PID of the process doing the job (on non-forking OS, PID of the worker, otherwise forked PID). |
||
| 27 | */ |
||
| 28 | public static function get($id) |
||
| 29 | { |
||
| 30 | return (int)Resque::redis()->get('job:' . $id . ':pid'); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Remove the PID tracker for the job. |
||
| 35 | * |
||
| 36 | * @param string $id The ID of the job to remove the tracker from. |
||
| 37 | */ |
||
| 38 | public static function del($id) |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 |