Skip to content

Commit

Permalink
Merge pull request #18 from sitewards/ADHOC-add-async-support
Browse files Browse the repository at this point in the history
ADHOC feat async-import: make things faster through parallel run
  • Loading branch information
aboritskiy authored Jun 10, 2021
2 parents 53b4748 + cae79d1 commit a1586d3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
16 changes: 16 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,19 @@ magento_force_reindex_on_deploy: False
# and more
# and more
# and more

# allows to run deletion of old clones folders asynchronously,
# this allows pipeline to finish faster due to "parallel" execution of tasks
# when clones are cleaned up asynchronously, role is not checking successful execution
magento_allow_async_cleanup_old_clones: false

# timeout for async old clones cleanup, seconds
magento_async_cleanup_old_clones_timeout: 600

# allows to run magento reindexing asynchronously,
# this allows pipeline to finish faster due to "parallel" execution of tasks
# when reindexing is done asynchronously, role is not checking successful execution
magento_allow_async_reindex: false

# timeout for async reindex execution, seconds
magento_async_reindex_timeout: 600
13 changes: 11 additions & 2 deletions tasks/cleanup-old-clones.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@
age_stamp: "ctime"
register: magento_clones_for_cleanup

- name: "Remove old clones/releases"
- name: "Remove old clones/releases asynchronously"
file:
path: "{{ item.path }}"
state: absent
when: magento_cleanup_old_clones == True
when: magento_cleanup_old_clones and magento_allow_async_cleanup_old_clones
with_items: "{{ (magento_clones_for_cleanup.files | sort(attribute='ctime', reverse=True))[magento_clones_to_keep:] | list }}"
async: "{{ magento_async_cleanup_old_clones_timeout }}"
poll: 0

- name: "Remove old clones/releases synchronously"
file:
path: "{{ item.path }}"
state: absent
when: magento_cleanup_old_clones and (not magento_allow_async_cleanup_old_clones)
with_items: "{{ (magento_clones_for_cleanup.files | sort(attribute='ctime', reverse=True))[magento_clones_to_keep:] | list }}"
12 changes: 10 additions & 2 deletions tasks/installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,19 @@
become_user: "{{ magento_user }}"
command: "/usr/bin/php {{ magento_app_root }}/bin/magento cache:flush"

- name: "Let Magento indexer run"
- name: "Let Magento indexer run asynchronously"
become: "yes"
become_user: "{{ magento_user }}"
command: "/usr/bin/php {{ magento_app_root }}/bin/magento indexer:reindex"
when: magento_db_status.stdout_lines|length == 0 or magento_force_reindex_on_deploy == True
when: (magento_db_status.stdout_lines|length == 0 or magento_force_reindex_on_deploy == True) and magento_allow_async_reindex
async: "{{ magento_async_reindex_timeout }}"
poll: 0

- name: "Let Magento indexer run synchronously"
become: "yes"
become_user: "{{ magento_user }}"
command: "/usr/bin/php {{ magento_app_root }}/bin/magento indexer:reindex"
when: (magento_db_status.stdout_lines|length == 0 or magento_force_reindex_on_deploy == True) and (not magento_allow_async_reindex)

- name: "Disable maintenance mode"
file:
Expand Down

0 comments on commit a1586d3

Please sign in to comment.