-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added celery task to send email initation
- Loading branch information
Showing
9 changed files
with
107 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,4 +46,8 @@ databases[postgresql] | |
faker | ||
factory-boy | ||
pytest-asyncio | ||
pytest-mock | ||
pytest-mock | ||
aiofiles | ||
celery | ||
redis | ||
flower |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from app.worker.celery import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
import asyncio | ||
|
||
from celery import Celery | ||
|
||
from app.services.mail import send_email_async | ||
|
||
|
||
celery = Celery(__name__) | ||
celery.conf.broker_url = os.environ.get("CELERY_BROKER_URL", "redis://localhost:6379") | ||
celery.conf.result_backend = os.environ.get("CELERY_RESULT_BACKEND", "redis://localhost:6379") | ||
|
||
|
||
@celery.task(name="send_email_task") | ||
def send_email_task(subject, email_to, body): | ||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(send_email_async(subject, email_to, body)) | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ services: | |
depends_on: | ||
- db | ||
- test-db | ||
- redis | ||
environment: | ||
- DATABASE_URL=postgresql://postgres:postgres@db/db | ||
- TEST_DATABASE_URL=postgresql://postgres:postgres@test-db/test-db | ||
|
@@ -27,6 +28,8 @@ services: | |
- INVITATION_URL_SECRET_KEY=INVITATION_URL_SECRET_KEY_HERE | ||
- INVITATION_URL_SECURITY_PASSWORD_SALT=INVITATION_URL_SECURITY_PASSWORD_SALT_HERE | ||
- INVITATION_URL_MAX_AGE=172800 | ||
- CELERY_BROKER_URL=redis://redis:6379/0 | ||
- CELERY_RESULT_BACKEND=redis://redis:6379/0 | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
|
@@ -58,6 +61,51 @@ services: | |
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD=postgres | ||
- POSTGRES_DB=test-db | ||
|
||
worker: | ||
build: . | ||
command: celery -A app.worker.celery worker --loglevel=info | ||
environment: | ||
- DATABASE_URL=postgresql://postgres:postgres@db/db | ||
- TEST_DATABASE_URL=postgresql://postgres:postgres@test-db/test-db | ||
- BASE_URL=http://localhost:8000 | ||
- APP_ENV=development | ||
- JWT_REFRESH_SECRET_KEY=JWT_REFRESH_SECRET_KEY_HERE | ||
- JWT_SECRET_KEY=WT_SECRET_KEY_HERE | ||
- ROLLBAR_ACCESS_TOKEN=ROLLBAR_ACCESS_TOKEN_HERE | ||
- BUCKET_NAME=BUCKET_NAME | ||
- OAUTH_CLIENT_ID=CLIENT_IDw | ||
- OAUTH_CLIENT_SECRET=OAUTH_CLIENT_SECRET | ||
- [email protected] | ||
- MAIL_PASSWORD=NupfGHXtsUdgx36VuK | ||
- [email protected] | ||
- MAIL_PORT=587 | ||
- MAIL_SERVER=smtp.ethereal.email | ||
- MAIL_FROM_NAME=Norval Hahn | ||
- INVITATION_URL_SECRET_KEY=INVITATION_URL_SECRET_KEY_HERE | ||
- INVITATION_URL_SECURITY_PASSWORD_SALT=INVITATION_URL_SECURITY_PASSWORD_SALT_HERE | ||
- INVITATION_URL_MAX_AGE=172800 | ||
- CELERY_BROKER_URL=redis://redis:6379/0 | ||
- CELERY_RESULT_BACKEND=redis://redis:6379/0 | ||
depends_on: | ||
- web | ||
- redis | ||
|
||
redis: | ||
image: redis:7 | ||
|
||
dashboard: | ||
build: . | ||
command: celery --broker=redis://redis:6379/0 flower --port=5555 | ||
ports: | ||
- 5556:5555 | ||
environment: | ||
- CELERY_BROKER_URL=redis://redis:6379/0 | ||
- CELERY_RESULT_BACKEND=redis://redis:6379/0 | ||
depends_on: | ||
- web | ||
- redis | ||
- worker | ||
|
||
volumes: | ||
db: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.