minor changes

This commit is contained in:
Emir Buğra Köksalan 2022-01-07 23:50:12 +03:00
parent 84f49e310b
commit aeda915563

View File

@ -15,7 +15,7 @@ while (true) {
$job = null; $job = null;
try { try {
$job = $pheanstalk->reserveWithTimeout(3); $job = $pheanstalk->reserveWithTimeout(10);
if (is_null($job)) if (is_null($job))
throw new Exception("Job is null"); throw new Exception("Job is null");
@ -26,7 +26,7 @@ while (true) {
echo date('Y-m-d H:i:s') . ' ' . str_pad($jobPayload->id, 5, " ", STR_PAD_LEFT) . ' ' . $jobPayload->date . PHP_EOL; echo date('Y-m-d H:i:s') . ' ' . str_pad($jobPayload->id, 5, " ", STR_PAD_LEFT) . ' ' . $jobPayload->date . PHP_EOL;
//echo date('Y-m-d H:i:s') . ' ' . str_pad($jobPayload->id, 5, " ", STR_PAD_LEFT) . ' ' . json_encode($jobPayload) . PHP_EOL; //echo date('Y-m-d H:i:s') . ' ' . str_pad($jobPayload->id, 5, " ", STR_PAD_LEFT) . ' ' . json_encode($jobPayload) . PHP_EOL;
usleep(mt_rand(1, 10)); usleep(mt_rand(1, 100));
//sleep(2); //sleep(2);
// If it's going to take a long time, periodically // If it's going to take a long time, periodically
// tell beanstalk we're alive to stop it rescheduling the job. // tell beanstalk we're alive to stop it rescheduling the job.
@ -41,10 +41,13 @@ while (true) {
$pheanstalk->release($job); $pheanstalk->release($job);
if (str_contains($e->getMessage(), 'Connection refused')) { if (str_contains($e->getMessage(), 'Connection refused')) {
echo 'Beanstalkd server is down'; echo 'Beanstalkd server is down' . PHP_EOL;
die(); die();
} else if (!($e instanceof Exception)) { } else if (!($e instanceof Exception)) {
echo $e->getMessage() . PHP_EOL; echo $e->getMessage() . PHP_EOL;
} else {
echo "Timeout reached." . PHP_EOL;
die();
} }
} }
} }