From b84d0c8d90d48a74cf6f2cb78eb7b8c3403071fe Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 3 Aug 2021 09:00:05 +0200 Subject: [PATCH] Update to 2021-08-03 09:00 --- roles/akeneo_pim/handlers/main.yml | 7 +++ roles/akeneo_pim/tasks/conf.yml | 57 ++++++++++++++++++++++ roles/akeneo_pim/tasks/install.yml | 16 ++++++ roles/akeneo_pim/tasks/services.yml | 8 +++ .../templates/akeneo-pim-events-api.service.j2 | 22 +++++++++ .../templates/akeneo-pim-jobs.service.j2 | 22 +++++++++ 6 files changed, 132 insertions(+) create mode 100644 roles/akeneo_pim/handlers/main.yml create mode 100644 roles/akeneo_pim/tasks/services.yml create mode 100644 roles/akeneo_pim/templates/akeneo-pim-events-api.service.j2 create mode 100644 roles/akeneo_pim/templates/akeneo-pim-jobs.service.j2 diff --git a/roles/akeneo_pim/handlers/main.yml b/roles/akeneo_pim/handlers/main.yml new file mode 100644 index 0000000..0d79c93 --- /dev/null +++ b/roles/akeneo_pim/handlers/main.yml @@ -0,0 +1,7 @@ +--- + +- name: restart akeneo-pim + service: name={{ item }} state=restarted + loop: + - akeneo-pim_{{ pim_id }}-jobs + - akeneo-pim_{{ pim_id }}-events-api diff --git a/roles/akeneo_pim/tasks/conf.yml b/roles/akeneo_pim/tasks/conf.yml index 3906899..e9770ff 100644 --- a/roles/akeneo_pim/tasks/conf.yml +++ b/roles/akeneo_pim/tasks/conf.yml @@ -30,3 +30,60 @@ command: "{{ pim_root_dir }}/perms.sh" when: pim_perm_script.changed or pim_install_mode != 'none' tags: pim + +- name: Setup cron jobs + cron: + cron_file: akeneopim_{{ pim_id }} + user: "{{ pim_user }}" + name: "{{ item.name }}" + job: /bin/php{{ pim_php_version }} {{ pim_root_dir }}/app/bin/console {{ item.job }} + minute: "{{ item.minute | default('*') }}" + hour: "{{ item.hour | default('*') }}" + weekday: "{{ item.weekday | default('*') }}" + day: "{{ item.day | default('*') }}" + month: "{{ item.month | default('*') }}" + loop: + - name: refresh + job: pim:versioning:refresh + minute: 30 + hour: 1 + - name: purge + job: pim:versioning:purge --more-than-days 90 --no-interaction --force + minute: 30 + hour: 2 + - name: update-data + job: akeneo:connectivity-audit:update-data + minute: 1 + - name: purge-errors + job: akeneo:connectivity-connection:purge-error + minute: 10 + - name: purge-job-execution + job: akeneo:batch:purge-job-execution + minute: 20 + hour: 0 + day: 1 + - name: purge-error-count + job: akeneo:connectivity-audit:purge-error-count + minute: 40 + hour: 0 + - name: aggregate + job: pim:volume:aggregate + minute: 30 + hour: 4 + - name: schedule-periodic-tasks + job: pim:data-quality-insights:schedule-periodic-tasks + minute: 15 + hour: 0 + - name: prepare-evaluations + job: pim:data-quality-insights:prepare-evaluations + minute: '*/10' + - name: evaluations + job: pim:data-quality-insights:evaluations + minute: '*/30' + - name: purge-messages + job: akeneo:messenger:doctrine:purge-messages messenger_messages default + minute: 0 + hour: '*/2' + tags: pim + + diff --git a/roles/akeneo_pim/tasks/install.yml b/roles/akeneo_pim/tasks/install.yml index aefd1cb..8d64b87 100644 --- a/roles/akeneo_pim/tasks/install.yml +++ b/roles/akeneo_pim/tasks/install.yml @@ -70,3 +70,19 @@ - pre - post tags: pim + +- name: Install job consumer and events api service units + template: src={{ item.src }} dest=/etc/systemd/system/{{ item.dest }} + loop: + - src: akeneo-pim-jobs.service.j2 + dest: akeneo-pim_{{ pim_id }}-jobs.service + - src: akeneo-pim-events-api.service.j2 + dest: akeneo-pim_{{ pim_id }}-events-api.service + register: pim_job_unit + notify: restart akeneo-pim + tags: pim + +- name: Reload systemd + systemd: daemon_reload=True + when: pim_job_unit.results | selectattr('changed','equalto',True) | list | length > 0 + tags: pim diff --git a/roles/akeneo_pim/tasks/services.yml b/roles/akeneo_pim/tasks/services.yml new file mode 100644 index 0000000..5970910 --- /dev/null +++ b/roles/akeneo_pim/tasks/services.yml @@ -0,0 +1,8 @@ +--- + +- name: Start services + service: name={{ item }} state=started enabled=True + loop: + - akeneo-pim_{{ pim_id }}-jobs + - akeneo-pim_{{ pim_id }}-events-api + tags: pim diff --git a/roles/akeneo_pim/templates/akeneo-pim-events-api.service.j2 b/roles/akeneo_pim/templates/akeneo-pim-events-api.service.j2 new file mode 100644 index 0000000..77ed1eb --- /dev/null +++ b/roles/akeneo_pim/templates/akeneo-pim-events-api.service.j2 @@ -0,0 +1,22 @@ +[Unit] +Description=Akeneo Events API worker for PIM {{ pim_id }} + +[Service] +User={{ pim_user }} +Group={{ pim_user }} +WorkingDirectory={{ pim_root_dir }}/app +ExecStart=/bin/php{{ pim_php_version }} bin/console messenger:consume webhook --env=prod +PrivateTmp=yes +PrivateDevices=yes +ProtectSystem=full +ProtectHome=yes +NoNewPrivileges=yes +MemoryLimit=1024M +SyslogIdentifier=akeneo-pim_{{ pim_id }}-events-api +Restart=on-failure +StartLimitInterval=0 +RestartSec=30 + +[Install] +WantedBy=multi-user.target + diff --git a/roles/akeneo_pim/templates/akeneo-pim-jobs.service.j2 b/roles/akeneo_pim/templates/akeneo-pim-jobs.service.j2 new file mode 100644 index 0000000..c5fd495 --- /dev/null +++ b/roles/akeneo_pim/templates/akeneo-pim-jobs.service.j2 @@ -0,0 +1,22 @@ +[Unit] +Description=Akeneo jobs worker for PIM {{ pim_id }} + +[Service] +User={{ pim_user }} +Group={{ pim_user }} +WorkingDirectory={{ pim_root_dir }}/app +ExecStart=/bin/php{{ pim_php_version }} bin/console akeneo:batch:job-queue-consumer-daemon --env=prod +PrivateTmp=yes +PrivateDevices=yes +ProtectSystem=full +ProtectHome=yes +NoNewPrivileges=yes +MemoryLimit=1024M +SyslogIdentifier=akeneo-pim_{{ pim_id }}-jobs +Restart=on-failure +StartLimitInterval=0 +RestartSec=30 + +[Install] +WantedBy=multi-user.target +