Skip to content

Feature/queueable print#1070

Merged
werrolf merged 25 commits into
release/3.0.7from
feature/queueable-print
Jan 21, 2019
Merged

Feature/queueable print#1070
werrolf merged 25 commits into
release/3.0.7from
feature/queueable-print

Conversation

@werrolf

@werrolf werrolf commented Jan 21, 2019

Copy link
Copy Markdown
Contributor

Optionally diverts print jobs into a database table to be picked up and executed by a console command.
This decouples job execution from the request context, and thus enables strictly serialized execution of demanding jobs with high resource limits without the risk of resource spikes.

This requires a bit of outside configuration which may be hard to accomplish depending on the OS, web server configuration and other platform factors. Web server and CLI will compete for cache regeneration and will have to share files, so they absolutely must be configured to run as compatible users.
Because we cannot assume clean user and system configuration, the queued printing behaviour is actually completely dormant unless the new mapbender.print.queueable parameter is set to true.

After enabling the global parameter, PrintClient Element backend forms gain a new renderMode dropdown ("direct" or "queued"; "direct" remains the default). I.e. you can still have direct-mode PrintClients. You can switch on an Application basis as appropriate, and you can even have direct-mode and queued-mode PrintClient Elements side by side in the same Application if you want.

For any jobs to get executed the mapbender:print:queue:next CLI must be run in one of three potential approaches:

  1. An endless loop. This can be accomplished in several ways, among them the Unix watch command. By default, each invocation processes at most one job before it exits, so there are no options to consider for this approach.
  2. As a potentially infinitely running single process
app/console mapbender:print:queue:next --max-jobs=0 --max-time=0
  1. As a longer-lived, but still regularly exiting cronjob. Each invocation should exit a little bit before the next one starts to avoid overlapping multiple processes executing resource-intensive jobs simultaneously. This opens a window of time where no jobs will get pulled out of the database for execution. This window should sit in a low-expectation period, like the middle of the night.
    Here are the options to run jobs (any number of them) for a whole day minus five minutes before process exit:
app/console mapbender:print:queue:next --max-jobs=0 --max-time=86100

Two additional container parameters are introduced:

  1. mapbender.print.queue.storage_dir specifies an absolute path for the generated PDF files
  2. mapbender.print.queue.memory_limit can extend (never reduce) the PHP memory limit at runtime, specifically for queued print job execution

@werrolf werrolf requested a review from DavidPatzke January 21, 2019 11:00
@werrolf werrolf merged commit de56874 into release/3.0.7 Jan 21, 2019
@werrolf werrolf deleted the feature/queueable-print branch January 28, 2019 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant