Skip to content

Conversation

@rfay
Copy link
Member

@rfay rfay commented Jul 21, 2022

  • Use crontab instead of putting things directly into /etc/cron.d. This makes commands run as the user instead of as root, avoiding permissions problems
  • Provide TYPO3 scheduler and drupal examples

This PR can be tested with ddev get https://github.com/rfay/ddev-cron/tarball/20220721_easier_perms_cron.d

The new README is at https://github.com/drud/ddev-cron/blob/8db9f512e8c1400a0f8363d75da2bb74aaa253bf/README.md

@rfay rfay requested a review from tyler36 July 21, 2022 17:20
@rfay rfay force-pushed the 20220721_easier_perms_cron.d branch from 4e332d2 to 9729db8 Compare July 21, 2022 18:32
@tyler36 tyler36 merged commit ce2b9d3 into ddev:main Jul 22, 2022
@tyler36
Copy link
Collaborator

tyler36 commented Jul 22, 2022

Thank you for this.

I saw the conversation on Discord and was planning on updating readme to include 'crontab'

@rfay rfay deleted the 20220721_easier_perms_cron.d branch July 22, 2022 02:30
@rfay
Copy link
Member Author

rfay commented Jul 22, 2022

I hadn't ever had any experience with the TYPO3 thing, but both TYPO3 and Drupal required extra effort because of how settings.ddev.php is only included if IS_DDEV_PROJECT, and for Drupal, also needed a trigger on DDEV_PHP_VERSION. I don't think that ddev_contrib recipe could have worked as it was, maybe I missed something.

@tyler36
Copy link
Collaborator

tyler36 commented Jul 22, 2022

It is one of the benefits of ddev addons. We have a chance to update the process and docs based on modern (current) frameworks.

@echavaillaz
Copy link
Contributor

Personally I have an error with the TYPO3 example:

PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] Connection refused in /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:40

To avoid having this error, I have to make ddev ssh and then /var/www/html/vendor/bin/typo3 scheduler:run

Any idea?

@rfay
Copy link
Member Author

rfay commented Jul 22, 2022

Hi @echavaillaz - Please show the actual hooks you're using.

I used this (from the README, https://github.com/drud/ddev-cron#examples and it worked fine.

What was missing earlier was the IS_DDEV_PROJECT=true. Please remove your existing hook and use the example, and maybe do a ddev get drud/ddev-cron again. (This PR was pulled, so you can use drud/ddev-cron directly.)

hooks:
  post-start:
    - exec: printf "SHELL=/bin/bash\n* * * * * date |& tee -a /var/www/html/date.log\n* * * * * IS_DDEV_PROJECT=true /var/www/html/vendor/bin/typo3 scheduler:run -vv |& tee -a /var/www/html/scheduler-log.txt\n" | crontab

As explained in the README (updated), you can experiment using the crontab command directly until you have it going.

@echavaillaz
Copy link
Contributor

Hi, thanks for the answer.

I try what you purpose but the error is still the same for me...

Thanks

@echavaillaz
Copy link
Contributor

I think the problem is that the cron don't take care of the web_environment env vars.
The env vars that are taken in account come from my main .env file and not from the DDEV config.

@rfay
Copy link
Member Author

rfay commented Jul 27, 2022

@echavaillaz please try a plain vanilla TYPO3 installation. Use the DDEV TYPO3 quickstart from the docs. Then ddev get drud/ddev-cron. See if it works. Then you can proceed to look at the difference between a regular TYPO3 installation and yours. From https://ddev.readthedocs.io/en/latest/users/quickstart/

mkdir my-typo3-site
cd my-typo3-site
ddev config --project-type=typo3 --docroot=public --create-docroot
ddev start
ddev composer create "typo3/cms-base-distribution" --no-install
ddev composer install
ddev exec touch public/FIRST_INSTALL
ddev launch
ddev get drud/ddev-cron

@rfay
Copy link
Member Author

rfay commented Jul 28, 2022

This isn't the place to discuss this, it needs a new issue, or we can talk more in discord, but I know it can work for you. I spent half a day sorting out the basic issue, so feel very familiar with it. We can do a screenshare call if you like.

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.

3 participants