Skip to content

Commit c2c4d06

Browse files
committed
Working blocking list pop :)
1 parent 132531e commit c2c4d06

File tree

14 files changed

+606
-177
lines changed

14 files changed

+606
-177
lines changed

bin/resque

100644100755
Lines changed: 2 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,3 @@
1+
#!/usr/bin/env php
12
<?php
2-
3-
// Find and initialize Composer
4-
$files = array(
5-
__DIR__ . '/../../vendor/autoload.php',
6-
__DIR__ . '/../../../autoload.php',
7-
__DIR__ . '/../../../../autoload.php',
8-
__DIR__ . '/../vendor/autoload.php',
9-
);
10-
11-
$found = false;
12-
foreach ($files as $file) {
13-
if (file_exists($file)) {
14-
require_once $file;
15-
break;
16-
}
17-
}
18-
19-
if (!class_exists('Composer\Autoload\ClassLoader', false)) {
20-
die(
21-
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
22-
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
23-
'php composer.phar install' . PHP_EOL
24-
);
25-
}
26-
27-
$QUEUE = getenv('QUEUE');
28-
if(empty($QUEUE)) {
29-
die("Set QUEUE env var containing the list of queues to work.\n");
30-
}
31-
32-
$REDIS_BACKEND = getenv('REDIS_BACKEND');
33-
$REDIS_BACKEND_DB = getenv('REDIS_BACKEND_DB');
34-
if(!empty($REDIS_BACKEND)) {
35-
if (empty($REDIS_BACKEND_DB))
36-
Resque::setBackend($REDIS_BACKEND);
37-
else
38-
Resque::setBackend($REDIS_BACKEND, $REDIS_BACKEND_DB);
39-
}
40-
41-
$logLevel = 0;
42-
$LOGGING = getenv('LOGGING');
43-
$VERBOSE = getenv('VERBOSE');
44-
$VVERBOSE = getenv('VVERBOSE');
45-
if(!empty($LOGGING) || !empty($VERBOSE)) {
46-
$logLevel = Resque_Worker::LOG_NORMAL;
47-
}
48-
else if(!empty($VVERBOSE)) {
49-
$logLevel = Resque_Worker::LOG_VERBOSE;
50-
}
51-
52-
$APP_INCLUDE = getenv('APP_INCLUDE');
53-
if($APP_INCLUDE) {
54-
if(!file_exists($APP_INCLUDE)) {
55-
die('APP_INCLUDE ('.$APP_INCLUDE.") does not exist.\n");
56-
}
57-
58-
require_once $APP_INCLUDE;
59-
}
60-
61-
$interval = 5;
62-
$INTERVAL = getenv('INTERVAL');
63-
if(!empty($INTERVAL)) {
64-
$interval = $INTERVAL;
65-
}
66-
67-
$count = 1;
68-
$COUNT = getenv('COUNT');
69-
if(!empty($COUNT) && $COUNT > 1) {
70-
$count = $COUNT;
71-
}
72-
73-
if($count > 1) {
74-
for($i = 0; $i < $count; ++$i) {
75-
$pid = Resque::fork();
76-
if($pid == -1) {
77-
die("Could not fork worker ".$i."\n");
78-
}
79-
// Child, start the worker
80-
else if(!$pid) {
81-
$queues = explode(',', $QUEUE);
82-
$worker = new Resque_Worker($queues);
83-
$worker->logLevel = $logLevel;
84-
fwrite(STDOUT, '*** Starting worker '.$worker."\n");
85-
$worker->work($interval);
86-
break;
87-
}
88-
}
89-
}
90-
// Start a single worker
91-
else {
92-
$queues = explode(',', $QUEUE);
93-
$worker = new Resque_Worker($queues);
94-
$worker->logLevel = $logLevel;
95-
96-
$PIDFILE = getenv('PIDFILE');
97-
if ($PIDFILE) {
98-
file_put_contents($PIDFILE, getmypid()) or
99-
die('Could not write PID information to ' . $PIDFILE);
100-
}
101-
102-
fwrite(STDOUT, '*** Starting worker '.$worker."\n");
103-
$worker->work($interval);
104-
}
105-
?>
3+
include("resque.php");

bin/resque.php

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
// Find and initialize Composer
3+
$files = array(
4+
__DIR__ . '/../../vendor/autoload.php',
5+
__DIR__ . '/../../../autoload.php',
6+
__DIR__ . '/../../../../autoload.php',
7+
__DIR__ . '/../vendor/autoload.php',
8+
);
9+
10+
$found = false;
11+
foreach ($files as $file) {
12+
if (file_exists($file)) {
13+
require_once $file;
14+
break;
15+
}
16+
}
17+
18+
if (!class_exists('Composer\Autoload\ClassLoader', false)) {
19+
die(
20+
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
21+
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
22+
'php composer.phar install' . PHP_EOL
23+
);
24+
}
25+
26+
$QUEUE = getenv('QUEUE');
27+
if(empty($QUEUE)) {
28+
die("Set QUEUE env var containing the list of queues to work.\n");
29+
}
30+
31+
$REDIS_BACKEND = getenv('REDIS_BACKEND');
32+
$REDIS_BACKEND_DB = getenv('REDIS_BACKEND_DB');
33+
if(!empty($REDIS_BACKEND)) {
34+
if (empty($REDIS_BACKEND_DB))
35+
Resque::setBackend($REDIS_BACKEND);
36+
else
37+
Resque::setBackend($REDIS_BACKEND, $REDIS_BACKEND_DB);
38+
}
39+
40+
$logLevel = 0;
41+
$LOGGING = getenv('LOGGING');
42+
$VERBOSE = getenv('VERBOSE');
43+
$VVERBOSE = getenv('VVERBOSE');
44+
if(!empty($LOGGING) || !empty($VERBOSE)) {
45+
$logLevel = Resque_Worker::LOG_NORMAL;
46+
}
47+
else if(!empty($VVERBOSE)) {
48+
$logLevel = Resque_Worker::LOG_VERBOSE;
49+
}
50+
51+
$BLOCKING = getenv('BLOCKING') !== FALSE;
52+
53+
$APP_INCLUDE = getenv('APP_INCLUDE');
54+
if($APP_INCLUDE) {
55+
if(!file_exists($APP_INCLUDE)) {
56+
die('APP_INCLUDE ('.$APP_INCLUDE.") does not exist.\n");
57+
}
58+
59+
require_once $APP_INCLUDE;
60+
}
61+
62+
$interval = 5;
63+
$INTERVAL = getenv('INTERVAL');
64+
if(!empty($INTERVAL)) {
65+
$interval = $INTERVAL;
66+
}
67+
68+
$count = 1;
69+
$COUNT = getenv('COUNT');
70+
if(!empty($COUNT) && $COUNT > 1) {
71+
$count = $COUNT;
72+
}
73+
74+
if($count > 1) {
75+
for($i = 0; $i < $count; ++$i) {
76+
$pid = Resque::fork();
77+
if($pid == -1) {
78+
die("Could not fork worker ".$i."\n");
79+
}
80+
// Child, start the worker
81+
else if(!$pid) {
82+
$queues = explode(',', $QUEUE);
83+
$worker = new Resque_Worker($queues);
84+
$worker->logLevel = $logLevel;
85+
fwrite(STDOUT, '*** Starting worker '.$worker."\n");
86+
$worker->work($interval, $BLOCKING);
87+
break;
88+
}
89+
}
90+
}
91+
// Start a single worker
92+
else {
93+
$queues = explode(',', $QUEUE);
94+
$worker = new Resque_Worker($queues);
95+
$worker->logLevel = $logLevel;
96+
97+
$PIDFILE = getenv('PIDFILE');
98+
if ($PIDFILE) {
99+
file_put_contents($PIDFILE, getmypid()) or
100+
die('Could not write PID information to ' . $PIDFILE);
101+
}
102+
103+
fwrite(STDOUT, '*** Starting worker '.$worker."\n");
104+
$worker->work($interval, $BLOCKING);
105+
}

0 commit comments

Comments
 (0)