Sending e-mail async with celery#4483
Conversation
|
The tests were the most difficult part of this but I think the mocking makes sense. Seems like lots of these unit tests were acting more like integration tests & encompassing a lot more logic than it should. I was also wondering if the auth/account creation email logic should be using the same |
99a2d82 to
86cbeff
Compare
|
Deploying to test now. I added "Heroku Key-Value Store" and made the following settings. |
|
When adding "Heroku Key-Value Store" a setting |
|
Removed from test now. Need to figure some things out since messages are not getting sent. The URLs need to look something like this: Without I think we could set The |
|
Added the "redis" packages in a separate commit to this PR, got error messages without it. With |
|
This is something we should have added to Hypha a long time ago. Nice work getting this off the ground @wes! |
If we're not using TLS for the broker I think we use
I must've left this out of my commit, thanks for adding it!
This is also good to know, I didn't realize that! |
|
For Heroku it's all inside AWS but other implementors we have no control over. I think it is safer to always go with TLS. |
|
@frjo I got TLS working with
that docker setup requires Redis TLS certs to be generated in a directory located at if we do add the cert config to the |
|
I've been digging in this all week and can't figure out what is happening here - with the new
and the celery worker connects to redis without error, but the tasks are just silently not passed to the queue. No errors and |
| if REDIS_URL and not (CELERY_BROKER_URL or CELERY_RESULT_BACKEND): | ||
| cert_param = "" | ||
| if REDIS_URL.startswith("rediss") and REDIS_SSL_CERT_REQS: | ||
| cert_param = f"?ssl_cert_reqs={REDIS_SSL_CERT_REQS}" | ||
| CELERY_BROKER_URL = f"{REDIS_URL}/0{cert_param}" | ||
| CELERY_RESULT_BACKEND = f"{REDIS_URL}{cert_param}" | ||
| os.environ["CELERY_BROKER_URL"] = CELERY_BROKER_URL | ||
| os.environ["CELERY_RESULT_BACKEND"] = CELERY_RESULT_BACKEND |
There was a problem hiding this comment.
not in love with this solution in general but it works - seems like celery is kinda weird and under-documented when it comes to configuration options, some folks in celery/celery#4284 had similar issues to what I was seeing.
open to any optimizations for this! but should fix our heroku config issues
There was a problem hiding this comment.
No, not that pretty. But that it works is a clear benefit 👍 .
Perhaps add a comment about why it looks like it does.
|
Deploying to test now. |
|
Edit: Looks like Sentry integration should work out of the box!
|
|
@theskumar I read that earlier, pretty sweet! Do you think we still need to add |
8457708 to
fb2ab54
Compare
d837c8f to
5d5a06f
Compare
No. Initially I was a little confused as the official docs say nothing is needed, but we are using |
|
@wes-otf just a small thing, I believe it's a good time to update |
…onverted diagram to mermaid
c593324 to
41c55b9
Compare
|
@theskumar should be all set, I also redid the existing diagram with mermaid which is pretty cool! never used it before |
Looking great! I was thinking of doing the same. Mermaid is really great for maintainable diagrams, but if you need something more complicated, concise, or fancy, it's better done custom. |
|
@frjo anything left on this or are we ready to merge? |
This does a full implementation of celery for sending emails. The functionality was already partially implemented but wasn't properly configured to be used app-wide nor was it ever enabled.
Running locally
docker run -d -p 6379:6379 redis)SEND_MESSAGES=Trueso emails will appear in terminalCELERY_TASK_ALWAYS_EAGER=Falseso celery will add tasks to the broker rather than run it immediatelyCELERY_BROKER_URL&CELERY_RESULT_BACKENDare properly set to your brokermake serve(but with same environment vars), runcelery -A hypha.celery worker -E --loglevel=infoto start celeryTest Steps