Génération PDF asynchrone : jobs avec polling + progression
All checks were successful
Deploy / deploy (push) Successful in 20s
All checks were successful
Deploy / deploy (push) Successful in 20s
- Nouveau système de jobs : POST /jobs (async), GET /jobs/{id} (status), GET /jobs/{id}/result (PDF), DELETE /jobs/{id}
- worker.php spawné en arrière-plan via nohup, lit la sortie pagedjs-cli ligne par ligne via proc_open et écrit la progression dans tmp/job_{id}.status.json
- Migration de pagedjs-cli en install local (node_modules) pour persister le patch protocolTimeout via patch-package
- CI : déploie package.json, worker.php, patches/, et lance npm install (qui réapplique les patches via postinstall)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a005c982bd
commit
0b954ed494
10 changed files with 506 additions and 6 deletions
|
|
@ -50,11 +50,31 @@ if (!$auth->authenticate()) {
|
|||
exit;
|
||||
}
|
||||
|
||||
// Endpoint de génération PDF
|
||||
// Endpoints
|
||||
if ($uri === '/generate') {
|
||||
// Endpoint synchrone existant (rétro-compat)
|
||||
$generator = new \Web2Print\Services\PdfGenerator($config);
|
||||
$controller = new \Web2Print\Controllers\GenerateController($generator, $config);
|
||||
$controller->handle();
|
||||
} elseif ($uri === '/jobs') {
|
||||
// POST /jobs : créer un job async
|
||||
$jobs = new \Web2Print\Services\JobManager($config);
|
||||
$controller = new \Web2Print\Controllers\JobsController($jobs, $config);
|
||||
$controller->create();
|
||||
} elseif (preg_match('#^/jobs/([a-f0-9]+)/result$#', $uri, $m)) {
|
||||
// GET /jobs/{id}/result : récupérer le PDF
|
||||
$jobs = new \Web2Print\Services\JobManager($config);
|
||||
$controller = new \Web2Print\Controllers\JobsController($jobs, $config);
|
||||
$controller->result($m[1]);
|
||||
} elseif (preg_match('#^/jobs/([a-f0-9]+)$#', $uri, $m)) {
|
||||
// GET /jobs/{id} : status — DELETE /jobs/{id} : cleanup
|
||||
$jobs = new \Web2Print\Services\JobManager($config);
|
||||
$controller = new \Web2Print\Controllers\JobsController($jobs, $config);
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'DELETE') {
|
||||
$controller->delete($m[1]);
|
||||
} else {
|
||||
$controller->status($m[1]);
|
||||
}
|
||||
} else {
|
||||
http_response_code(404);
|
||||
header('Content-Type: application/json');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue