1 | <?php |
||||
2 | |||||
3 | // Look for an environment variable with |
||||
4 | $RESQUE_PHP = getenv('RESQUE_PHP'); |
||||
5 | if (!empty($RESQUE_PHP)) { |
||||
6 | require_once $RESQUE_PHP; |
||||
7 | } |
||||
8 | // Otherwise, if we have no Resque then assume it is in the include path |
||||
9 | else if (!class_exists('Resque')) { |
||||
10 | require_once 'Resque/Resque.php'; |
||||
11 | } |
||||
12 | |||||
13 | // Load resque-scheduler |
||||
14 | require_once dirname(__FILE__) . '/lib/ResqueScheduler.php'; |
||||
15 | require_once dirname(__FILE__) . '/lib/ResqueScheduler/Worker.php'; |
||||
16 | |||||
17 | $REDIS_BACKEND = getenv('REDIS_BACKEND'); |
||||
18 | $REDIS_BACKEND_DB = getenv('REDIS_BACKEND_DB'); |
||||
19 | if(!empty($REDIS_BACKEND)) { |
||||
20 | if (empty($REDIS_BACKEND_DB)) |
||||
21 | Resque::setBackend($REDIS_BACKEND); |
||||
22 | else |
||||
23 | Resque::setBackend($REDIS_BACKEND, $REDIS_BACKEND_DB); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
24 | } |
||||
25 | |||||
26 | // Set log level for resque-scheduler |
||||
27 | $logLevel = 0; |
||||
28 | $LOGGING = getenv('LOGGING'); |
||||
29 | $VERBOSE = getenv('VERBOSE'); |
||||
30 | $VVERBOSE = getenv('VVERBOSE'); |
||||
31 | if(!empty($LOGGING) || !empty($VERBOSE)) { |
||||
32 | $logLevel = ResqueScheduler_Worker::LOG_NORMAL; |
||||
33 | } |
||||
34 | else if(!empty($VVERBOSE)) { |
||||
35 | $logLevel = ResqueScheduler_Worker::LOG_VERBOSE; |
||||
36 | } |
||||
37 | |||||
38 | // Check for jobs every $interval seconds |
||||
39 | $interval = 5; |
||||
40 | $INTERVAL = getenv('INTERVAL'); |
||||
41 | if(!empty($INTERVAL)) { |
||||
42 | $interval = $INTERVAL; |
||||
43 | } |
||||
44 | |||||
45 | // Load the user's application if one exists |
||||
46 | $APP_INCLUDE = getenv('APP_INCLUDE'); |
||||
47 | if($APP_INCLUDE) { |
||||
48 | if(!file_exists($APP_INCLUDE)) { |
||||
49 | die('APP_INCLUDE ('.$APP_INCLUDE.") does not exist.\n"); |
||||
50 | } |
||||
51 | |||||
52 | require_once $APP_INCLUDE; |
||||
53 | } |
||||
54 | |||||
55 | $PREFIX = getenv('PREFIX'); |
||||
56 | if(!empty($PREFIX)) { |
||||
57 | fwrite(STDOUT, '*** Prefix set to '.$PREFIX."\n"); |
||||
58 | Resque_Redis::prefix($PREFIX); |
||||
59 | } |
||||
60 | |||||
61 | $worker = new ResqueScheduler_Worker(); |
||||
62 | $worker->logLevel = $logLevel; |
||||
63 | |||||
64 | $PIDFILE = getenv('PIDFILE'); |
||||
65 | if ($PIDFILE) { |
||||
66 | file_put_contents($PIDFILE, getmypid()) or |
||||
67 | die('Could not write PID information to ' . $PIDFILE); |
||||
68 | } |
||||
69 | |||||
70 | fwrite(STDOUT, "*** Starting scheduler worker\n"); |
||||
71 | $worker->work($interval); |
||||
0 ignored issues
–
show
It seems like
$interval can also be of type string ; however, parameter $interval of ResqueScheduler_Worker::work() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
72 |