Skip to content
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

💡 Document "provisioning" crons on deploy #482

Open
chrillep opened this issue Oct 18, 2023 · 1 comment
Open

💡 Document "provisioning" crons on deploy #482

chrillep opened this issue Oct 18, 2023 · 1 comment

Comments

@chrillep
Copy link
Contributor

chrillep commented Oct 18, 2023

Summary

One could argue that crons should be part of the deploy. 😄
How do we accomplish this?
It would really help me if this was part of the trellis docs. 🙏🏼

AC: (feel free to change them) ❤️

Docs

  • Should contain how cron works or link to it. (it has become apparent to me, that this is forgotten knowledge 😺. Spanning from an ancient time)
    • cron as in the system
    • cron as in how you apply it
  • Should contain examples of how you provision crons
  • Should contain examples on how to update "provision" crons on deploy.
  • Should contain descriptions on what each value does in the cron config
  • Should contain how you test crons
  • Should contain links of Best practices on how to add schedule WP Cron events

Additional context

On most of our servers we dont have root access, so we only use the deploy part of trellis.
This is from what i gather a common practice?

It would be simpler (for us 😄 ) if the cron was part of the deploy.
It would be simpler (for us 😄 ) if the user owning the crons was the deploy user.

refs

@chrillep chrillep changed the title 💡 document "provisioning" cron on deploy 💡 Document "provisioning" cron on deploy Oct 18, 2023
@chrillep chrillep changed the title 💡 Document "provisioning" cron on deploy 💡 Document "provisioning" crons on deploy Oct 18, 2023
@retlehs retlehs transferred this issue from roots/trellis Oct 18, 2023
@chrillep
Copy link
Contributor Author

working yaml if you want || need the crons to be setup as part of the deploy chain.

trellis/deploy-hooks/build-before.yml

- name: Setup WP system cron using crontab
  shell: |
    (crontab -l 2>/dev/null || echo '') | grep -v "{{ item.key }} WordPress cron" | crontab -
    (crontab -l; echo "*/{{ item.value.cron_interval | default('5') }} * * * * cd {{ www_root }}/{{ item.value.current_path | default('current') }} && wp cron event run --due-now > /dev/null 2>&1 # {{ item.key }} WordPress cron") | crontab -
  loop: "{{ wordpress_sites | dict2items }}"
  loop_control:
    label: "{{ item.key }}"
  when: not item.value.multisite.enabled

- name: Setup WP Multisite system cron using crontab
  shell: |
    (crontab -l 2>/dev/null || echo '') | grep -v "{{ item.key }} WordPress network cron" | crontab -
    (crontab -l; echo "*/{{ item.value.cron_interval_multisite | default('10') }} * * * * cd {{ www_root }}/{{ item.value.current_path | default('current') }} && (wp site list --field=url | xargs -n1 -I \\% wp --url=\\% cron event run --due-now) > /dev/null 2>&1 # {{ item.key }} WordPress network cron") | crontab -
  loop: "{{ wordpress_sites | dict2items }}"
  loop_control:
    label: "{{ item.key }}"
  when: item.value.multisite.enabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants