try { $job = $pheanstalk->peekDelayed($tube); $statsJob = $pheanstalk->statsJob($job); $jobDelayed = ['data' => $job->getData(), 'stats' => $statsJob]; } catch (\Pheanstalk\Exception\ServerException $e) { $jobDelayed = null; } try { $job = $pheanstalk->peekReady($tube); $statsJob = $pheanstalk->statsJob($job); $jobReady = ['data' => $job->getData(), 'stats' => $statsJob]; } catch (\Pheanstalk\Exception\ServerException $e) { $jobReady = null; } $statsTube = $pheanstalk->statsTube($tube)->getArrayCopy(); $stats = $pheanstalk->stats()->getArrayCopy(); $tubes = $pheanstalk->listTubes(); } catch (\Pheanstalk\Exception\ConnectionException $e) { $isServiceListening = false; $jobBuried = null; $jobDelayed = null; $jobReady = null; $statsTube = []; $stats = []; $tubes = []; } $r = $res->withHeader('Content-Type', 'application/json'); $r->write(json_encode(['isServiceListening' => $isServiceListening, 'jobBuried' => $jobBuried, 'jobDelayed' => $jobDelayed, 'jobReady' => $jobReady, 'serverAddress' => $config['beanstalk_server'], 'statsTube' => $statsTube, 'stats' => $stats, 'tubes' => $tubes])); return $r; }); $app->post('/cmd/delete', function ($req, $res) use($pheanstalk) {