-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preview generator setup #7
Conversation
Enable the variable nextcloud_preview_enabled and you are good to go. Some important aspects of usage: - the preview generator has two stages [according to their readme](https://github.com/nextcloud/previewgenerator) - a generate-all phase, which has to be executed only a single time - a pre-generate phase, that should be run in a cronjob. That runs quite fast if the generate-all phase finishd. We do not want to run the generate-all phase multiple times, so its execution has to be followed somehow. This is done by creating a file on the host side and both the task that executes generate-all and both the cronjob checks its existance. Multiple vaiables are also defined and the corresponding default values are also set. These values are based on the [upstream readme](https://github.com/nextcloud/previewgenerator) and also on experience. Feel free to change anything. Once installed, the playbook needs to be called with the adjust-nextcloud-config tag. This tag sets up the variables and calls the generate-all script, that will also create the file---signalling its finished state---on the host. *** As this may take a long time, be sure to only call it when you have time to leave it running!!! *** The playbook calls generate-all asynchronously, but it will timeout after about 27h. On 60GBs, most if images, it took about 10 minutes to finish. If it takes more time, you may want to start it from the host by calling ```sh /usr/bin/env docker exec mash-nextcloud-server php /var/www/html/occ preview:generate-all ``` If the nextcloud_preview_enabled value is set back to false, the host side files are cleaned up and also the cron job is changed, not to call prevew generation again however, the database and generated previews are kept intact.
tasks/adjust_config.yml
Outdated
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many blank lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the blank lines
tasks/adjust_config.yml
Outdated
- when: nextcloud_preview_enabled | bool | ||
name: Setup preview generator squareSizes | ||
ansible.builtin.command: | ||
cmd: |- | ||
docker exec --user={{ nextcloud_uid }}:{{ nextcloud_gid }} {{ nextcloud_identifier }}-server php /var/www/html/occ config:app:set previewgenerator squareSizes --value={{ nextcloud_preview_squareSizes }} | ||
|
||
- when: nextcloud_preview_enabled | bool | ||
name: Setup preview generator widthSizes | ||
ansible.builtin.command: | ||
cmd: |- | ||
docker exec --user={{ nextcloud_uid }}:{{ nextcloud_gid }} {{ nextcloud_identifier }}-server php /var/www/html/occ config:app:set previewgenerator widthSizes --value={{ nextcloud_preview_widthSizes }} | ||
|
||
- when: nextcloud_preview_enabled | bool | ||
name: Setup preview generator heightSizes | ||
ansible.builtin.command: | ||
cmd: |- | ||
docker exec --user={{ nextcloud_uid }}:{{ nextcloud_gid }} {{ nextcloud_identifier }}-server php /var/www/html/occ config:app:set previewgenerator heightSizes --value={{ nextcloud_preview_heightSizes }} | ||
|
||
- when: nextcloud_preview_enabled | bool | ||
name: Setup preview generator preview_max_x | ||
ansible.builtin.command: | ||
cmd: |- | ||
docker exec --user={{ nextcloud_uid }}:{{ nextcloud_gid }} {{ nextcloud_identifier }}-server php /var/www/html/occ config:system:set preview_max_x --value {{ nextcloud_preview_preview_max_x }} | ||
|
||
- when: nextcloud_preview_enabled | bool | ||
name: Setup preview generator preview_max_y | ||
ansible.builtin.command: | ||
cmd: |- | ||
docker exec --user={{ nextcloud_uid }}:{{ nextcloud_gid }} {{ nextcloud_identifier }}-server php /var/www/html/occ config:system:set preview_max_y --value {{ nextcloud_preview_preview_max_y }} | ||
|
||
- when: nextcloud_preview_enabled | bool | ||
name: Setup preview generator config:system:set jpeg_quality | ||
ansible.builtin.command: | ||
cmd: |- | ||
docker exec --user={{ nextcloud_uid }}:{{ nextcloud_gid }} {{ nextcloud_identifier }}-server php /var/www/html/occ config:system:set jpeg_quality --value {{ nextcloud_preview_system_jpeg_quality }} | ||
|
||
- when: nextcloud_preview_enabled | bool | ||
name: Setup preview generator app:set preview jpeg_quality | ||
ansible.builtin.command: | ||
cmd: |- | ||
docker exec --user={{ nextcloud_uid }}:{{ nextcloud_gid }} {{ nextcloud_identifier }}-server php /var/www/html/occ config:app:set preview jpeg_quality --value={{ nextcloud_preview_app_jpeg_quality }} | ||
|
||
- when: nextcloud_preview_enabled | bool | ||
name: "Check if {{ nextcloud_preview_first_run_finished_filename }} exists" | ||
ansible.builtin.stat: | ||
path: "{{ nextcloud_preview_host_folder }}/{{ nextcloud_preview_first_run_finished_filename }}" | ||
register: nextcloud_preview_file_stats | ||
|
||
- when: nextcloud_preview_enabled | bool and not nextcloud_preview_file_stats.stat.exists | ||
name: Start preview generate-all | ||
ansible.builtin.command: | ||
cmd: |- | ||
docker exec --user={{ nextcloud_uid }}:{{ nextcloud_gid }} {{ nextcloud_identifier }}-server php /var/www/html/occ preview:generate-all | ||
async: 100000 | ||
poll: 10 | ||
|
||
- when: nextcloud_preview_enabled | bool | ||
name: Create file to signal, that first run is executed | ||
ansible.builtin.file: | ||
path: "{{ nextcloud_preview_host_folder }}/{{ nextcloud_preview_first_run_finished_filename }}" | ||
state: "touch" | ||
mode: 0644 | ||
owner: "{{ nextcloud_uid }}" | ||
group: "{{ nextcloud_gid }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having many tasks, each one with when: ...
, you can have a block
and nest them all inside.
Example:
- when: nextcloud_preview_enabled | bool
block:
- name: Setup preview generator squareSizes
.........
- name: Setup preview generator widthSizes
........
I suppose you could also make use of Ansible's with_items
and use a single task for many of these "set parameter" calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved everything into a single block and also merged the occ config set tasks
I incorporated your suggestions, please check it again @spantaleev |
Some instances seem to have trouble when overwritewebroot is set to `/`: > Dec 14 11:51:37 s3 systemd[1]: Starting Runs the cronjobs For Nextcloud (mash-nextcloud)... > Dec 14 11:51:37 s3 env[1246702]: Sabre\DAV\Exception\Forbidden: Requested uri (/remote.php/dav/) is out of base uri (//remote.php/dav/) in /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php:576 > Dec 14 11:51:37 s3 env[1246702]: Stack trace: > Dec 14 11:51:37 s3 env[1246702]: #0 /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php(542): Sabre\DAV\Server->calculateUri('/remote.php/dav...') > Dec 14 11:51:37 s3 env[1246702]: #1 /var/www/html/apps/photos/lib/Listener/SabrePluginAuthInitListener.php(50): Sabre\DAV\Server->getRequestUri() > Dec 14 11:51:37 s3 env[1246702]: #2 /var/www/html/lib/private/EventDispatcher/ServiceEventListener.php(86): OCA\Photos\Listener\SabrePluginAuthInitListener->handle(Object(OCA\DAV\Events\SabrePluginAuthInitEvent)) > Dec 14 11:51:37 s3 env[1246702]: #3 /var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php(230): OC\EventDispatcher\ServiceEventListener->__invoke(Object(OCA\DAV\Events\SabrePluginAuthInitEvent), 'OCA\\DAV\\Events\\...', Object(Symfony\Component\EventDispatcher\EventDispatcher)) > Dec 14 11:51:37 s3 env[1246702]: #4 /var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php(59): Symfony\Component\EventDispatcher\EventDispatcher->callListeners(Array, 'OCA\\DAV\\Events\\...', Object(OCA\DAV\Events\SabrePluginAuthInitEvent)) > Dec 14 11:51:37 s3 env[1246702]: #5 /var/www/html/lib/private/EventDispatcher/EventDispatcher.php(94): Symfony\Component\EventDispatcher\EventDispatcher->dispatch(Object(OCA\DAV\Events\SabrePluginAuthInitEvent), 'OCA\\DAV\\Events\\...') > Dec 14 11:51:37 s3 env[1246702]: #6 /var/www/html/lib/private/EventDispatcher/EventDispatcher.php(106): OC\EventDispatcher\EventDispatcher->dispatch('OCA\\DAV\\Events\\...', Object(OCA\DAV\Events\SabrePluginAuthInitEvent)) > Dec 14 11:51:37 s3 env[1246702]: #7 /var/www/html/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php(76): OC\EventDispatcher\EventDispatcher->dispatchTyped(Object(OCA\DAV\Events\SabrePluginAuthInitEvent)) > Dec 14 11:51:37 s3 env[1246702]: #8 [internal function]: OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer->__construct(true It seems like changing overwritewebroot to an empty string solves the problem there, and doesn't seem to be introducign regressions for installations that didn't have the problem in the first place.
Enable the variable nextcloud_preview_enabled and you are good to go.
Some important aspects of usage:
Multiple vaiables are also defined and the corresponding default values are also set. These values are based on the upstream readme and also on experience. Feel free to change anything.
Once installed, the playbook needs to be called with the adjust-nextcloud-config tag. This tag sets up the variables and calls the generate-all script, that will also create the file---signalling its finished state---on the host.
*** As this may take a long time, be sure to only call it when you have time to leave it running!!! *** The playbook calls generate-all asynchronously, but it will timeout after about 27h. On 60GBs, most if images, it took about 10 minutes to finish. If it takes more time, you may want to start it from the host by calling
/usr/bin/env docker exec mash-nextcloud-server php /var/www/html/occ preview:generate-all
If the nextcloud_preview_enabled value is set back to false, the host side files are cleaned up and also the cron job is changed, not to call prevew generation again however, the database and generated previews are kept intact.