Пример #1
0
        v::numeric()->setName('job_id')->check($job_id);
    } catch (ValidationExceptionInterface $e) {
        return $res->withStatus(400)->write($e->getMainMessage());
    }
    try {
        $job = new \Pheanstalk\Job($job_id, []);
        $pheanstalk->delete($job);
    } catch (\Pheanstalk\Exception\ServerException $e) {
        return $res->withStatus(400)->write($e->getMessage());
    }
});
$app->post('/cmd/kick', function ($req, $res) use($pheanstalk) {
    $job_id = $req->getParam('job_id');
    try {
        v::numeric()->setName('job_id')->check($job_id);
    } catch (ValidationExceptionInterface $e) {
        return $res->withStatus(400)->write($e->getMainMessage());
    }
    try {
        $job = new \Pheanstalk\Job($job_id, []);
        $pheanstalk->kickJob($job);
    } catch (\Pheanstalk\Exception\ServerException $e) {
        return $res->withStatus(400)->write($e->getMessage());
    }
});
$app->post('/cmd/pause', function ($req, $res) use($pheanstalk) {
    $tube = $req->getParam('tube', 'default');
    $duration = intval($req->getParam('duration', 60));
    $pheanstalk->pauseTube($tube, $duration);
});
$app->run();