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