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

Automated sendouts via cron job not working #14

Closed
andrewmenich opened this issue Aug 30, 2018 · 5 comments
Closed

Automated sendouts via cron job not working #14

andrewmenich opened this issue Aug 30, 2018 · 5 comments

Comments

@andrewmenich
Copy link

When trying to automate email sendouts via the Automated Sendout Type and cron job, the cron job does not successfully trigger the jobs queue to run. The cron job command is as written in the docs/settings: wget http://mywebsite.com/actions/campaign/sendouts/queue-pending-sendouts?key=HcNHpvyqclSQyVRb&run=1 >/dev/null 2>&1. Executed on Linode/Forge at an interval of every 1 minute.

If I hit that URL from a browser that is logged into Craft, the jobs queue will run as expected and any queued emails will be sent. However, if that URL is hit from a browser / server that is not logged into Craft (where the cron job is executed for example), the jobs queue will not run.

I interpreted the docs to mean thatrunQueueAutomatically should be set to false in order for the jobs queue to only run when triggered by the cron job. However, I tried runQueueAutomatically both true (default) and false, without luck.

I am currently only trying to send 1 email every 10 minutes, so I suspected I'm not hitting any batch thresholds. I am also currently in test mode, but I experienced the same issue when sending live emails.

Any help is greatly appreciated!

Versions:
Craft 3.0.21
Campaign 1.1.9
Campaign Pro 1.0.0
Server- Ubuntu 16.04.3 / Linux 4.15.13

@putyourlightson
Copy link
Collaborator

Hi Andrew. Your interpretation of the docs is correct and adding &run=1 should indeed trigger the queued job(s) to run. I just tested this locally and it worked fine for me. Can you please double check whether it works in a logged in browser window but not in a logged out browser window (or in incognito mode)?

@andrewmenich
Copy link
Author

andrewmenich commented Aug 30, 2018

Hi Ben, thanks for your assistance.

After further testing, I realize that when it seemed to be working was also when I had runQueueAutomatically as default (true) and that hitting the action URL of the cron was just hitting the control panel, thus running the jobs queue.

With runQueueAutomatically set to false and the cron job setup as described in settings, the jobs queue is not run when the cron is fired and no emails are sent.

@putyourlightson
Copy link
Collaborator

Tested this scenario locally and I still can't replicate your issue.

I wonder if your server setup is preventing the queue from being manually run, as Craft does some checks before allowing it to happen. Does setting runQueueAutomatically to false and using a cron job to manually run the queue work? See my original issue here for guidance.

@andrewmenich
Copy link
Author

Running /usr/bin/php /my_project_path/craft queue/run did indeed work, though it would only run what was in the queue, it wouldn't actually add items to the queue. The campaign cron job URL did do this, which led me to think that something with the &run=1 parameter wasn't getting registered.

Sure enough, the &run=1 parameter was getting interpreted incorrectly on my server(read more here), thus not actually running the jobs in the queue. The simple fix was to wrap the whole cron job URL in quotes. The automated sendouts are now sending automatically as expected.

I'm not sure how other servers/systems might interpret the URL, but it might be good to note this difference in the docs.

Also, one thing I noticed was that in test mode, logs were not being written to storage/runtime/debug/mail despite the sendout listing as sent. Is this a result of the cron job's >/dev/null 2>&1?

Thanks again for your assistance and for the great plugin.

@putyourlightson
Copy link
Collaborator

putyourlightson commented Sep 1, 2018

Ah excellent, thanks for the update and I'll add to the plugin in the next release.

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

No branches or pull requests

1 participant