@@ -42,9 +42,9 @@ $REDIS_BACKEND = getenv('REDIS_BACKEND');
42
42
$ REDIS_BACKEND_DB = getenv ('REDIS_BACKEND_DB ' );
43
43
if (!empty ($ REDIS_BACKEND )) {
44
44
if (empty ($ REDIS_BACKEND_DB ))
45
- Resque::setBackend ($ REDIS_BACKEND );
45
+ \ Resque \ Resque::setBackend ($ REDIS_BACKEND );
46
46
else
47
- Resque::setBackend ($ REDIS_BACKEND , $ REDIS_BACKEND_DB );
47
+ \ Resque \ Resque::setBackend ($ REDIS_BACKEND , $ REDIS_BACKEND_DB );
48
48
}
49
49
50
50
$ logLevel = false ;
@@ -70,7 +70,7 @@ if($APP_INCLUDE) {
70
70
// See if the APP_INCLUDE containes a logger object,
71
71
// If none exists, fallback to internal logger
72
72
if (!isset ($ logger ) || !is_object ($ logger )) {
73
- $ logger = new Resque_Log ($ logLevel );
73
+ $ logger = new \ Resque \ Logger ($ logLevel );
74
74
}
75
75
76
76
$ BLOCKING = getenv ('BLOCKING ' ) !== FALSE ;
@@ -89,8 +89,8 @@ if(!empty($COUNT) && $COUNT > 1) {
89
89
90
90
$ PREFIX = getenv ('PREFIX ' );
91
91
if (!empty ($ PREFIX )) {
92
- $ logger ->log (Psr \Log \LogLevel::INFO , 'Prefix set to {prefix} ' , array ('prefix ' => $ PREFIX ));
93
- Resque_Redis ::prefix ($ PREFIX );
92
+ $ logger ->log (\ Psr \Log \LogLevel::INFO , 'Prefix set to {prefix} ' , array ('prefix ' => $ PREFIX ));
93
+ \ Resque \Redis ::prefix ($ PREFIX );
94
94
}
95
95
96
96
function cleanup_children ($ signal ){
@@ -100,19 +100,19 @@ function cleanup_children($signal){
100
100
if ($ count > 1 ) {
101
101
$ children = array ();
102
102
$ GLOBALS ['send_signal ' ] = FALSE ;
103
-
103
+
104
104
$ die_signals = array (SIGTERM , SIGINT , SIGQUIT );
105
105
$ all_signals = array_merge ($ die_signals , array (SIGUSR1 , SIGUSR2 , SIGCONT , SIGPIPE ));
106
-
106
+
107
107
for ($ i = 0 ; $ i < $ count ; ++$ i ) {
108
- $ pid = Resque::fork ();
108
+ $ pid = \ Resque \ Resque::fork ();
109
109
if ($ pid == -1 ) {
110
110
die ("Could not fork worker " .$ i ."\n" );
111
111
}
112
112
// Child, start the worker
113
113
elseif (!$ pid ) {
114
114
$ queues = explode (', ' , $ QUEUE );
115
- $ worker = new Resque_Worker ($ queues );
115
+ $ worker = new \ Resque \ Worker \ ResqueWorker ($ queues );
116
116
$ worker ->logLevel = $ logLevel ;
117
117
$ worker ->hasParent = TRUE ;
118
118
fwrite (STDOUT , '*** Starting worker ' .$ worker ."\n" );
@@ -127,27 +127,27 @@ if($count > 1) {
127
127
foreach ($ all_signals as $ signal ) {
128
128
pcntl_signal ($ signal , "cleanup_children " );
129
129
}
130
-
130
+
131
131
$ PIDFILE = getenv ('PIDFILE ' );
132
132
if ($ PIDFILE ) {
133
133
if (file_put_contents ($ PIDFILE , getmypid ()) === false ){
134
- $ logger ->log (Psr \Log \LogLevel::NOTICE , 'Could not write PID information to {pidfile} ' , array ('pidfile ' => $ PIDFILE ));
134
+ $ logger ->log (\ Psr \Log \LogLevel::NOTICE , 'Could not write PID information to {pidfile} ' , array ('pidfile ' => $ PIDFILE ));
135
135
die (2 );
136
136
}
137
137
}
138
-
138
+
139
139
$ registered = TRUE ;
140
140
}
141
-
141
+
142
142
if (function_exists ('setproctitle ' )) {
143
- setproctitle ('resque- ' . Resque::VERSION . ": Monitoring {$ count } children: [ " .implode (', ' , array_keys ($ children ))."] " );
143
+ setproctitle ('resque- ' . \ Resque \ Resque::VERSION . ": Monitoring {$ count } children: [ " .implode (', ' , array_keys ($ children ))."] " );
144
144
}
145
-
145
+
146
146
$ childPID = pcntl_waitpid (-1 , $ childStatus , WNOHANG );
147
147
if ($ childPID != 0 ) {
148
148
fwrite (STDOUT , "*** A child worker died: {$ childPID }\n" );
149
149
unset($ children [$ childPID ]);
150
- $ i --;
150
+ $ i --;
151
151
}
152
152
usleep (250000 );
153
153
if ($ GLOBALS ['send_signal ' ] !== FALSE ){
@@ -169,19 +169,19 @@ if($count > 1) {
169
169
// Start a single worker
170
170
else {
171
171
$ queues = explode (', ' , $ QUEUE );
172
- $ worker = new Resque_Worker ($ queues );
172
+ $ worker = new \ Resque \ Worker \ ResqueWorker ($ queues );
173
173
$ worker ->logLevel = $ logLevel ;
174
174
$ worker ->hasParent = FALSE ;
175
175
176
176
$ PIDFILE = getenv ('PIDFILE ' );
177
177
if ($ PIDFILE ) {
178
178
if (file_put_contents ($ PIDFILE , getmypid ()) === false ) {
179
- $ logger ->log (Psr \Log \LogLevel::NOTICE , 'Could not write PID information to {pidfile} ' , array ('pidfile ' => $ PIDFILE ));
179
+ $ logger ->log (\ Psr \Log \LogLevel::NOTICE , 'Could not write PID information to {pidfile} ' , array ('pidfile ' => $ PIDFILE ));
180
180
die (2 );
181
181
}
182
182
}
183
183
184
- $ logger ->log (Psr \Log \LogLevel::NOTICE , 'Starting worker {worker} ' , array ('worker ' => $ worker ));
184
+ $ logger ->log (\ Psr \Log \LogLevel::NOTICE , 'Starting worker {worker} ' , array ('worker ' => $ worker ));
185
185
$ worker ->work ($ interval , $ BLOCKING );
186
186
}
187
187
?>
0 commit comments