Skip to content

Commit

Permalink
First draft of README
Browse files Browse the repository at this point in the history
  • Loading branch information
kacperlukawski committed Apr 8, 2020
1 parent a4762e5 commit 58c0bad
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
web: gunicorn application.wsgi
web: gunicorn application.wsgi
worker: celery worker --app=application.celery
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ Heroku one.
#### First steps

1. Login to your Heroku account from the console using `heroku login`.
2. Create a new Heroku project with `heroku create [APP_NAME]`.
2. Create a new Heroku project with `heroku create [APP_NAME]`.
This command allows to have several
3. Provision a PostgreSQL database with
`heroku addons:create heroku-postgresql:hobby-dev`.
4. Provision a RabbitMQ task queue with `heroku addons:create cloudamqp:lemur`
(that requires to have a credit card configured on Heroku).

### Choosing Celery broker

Expand Down Expand Up @@ -68,6 +73,8 @@ be used as a base for different environments. Providing a postfix to the file
name, like ".env.production" is a common strategy, and we'll do so in all the
examples below.

See: https://devcenter.heroku.com/articles/multiple-environments

### Important files

## Application structure
Expand Down
17 changes: 17 additions & 0 deletions application/celery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os

from celery import Celery

# set the default Django settings module for the "celery" program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "application.settings")

app = Celery("tasks")

# Using a string here means the worker doesn"t have to serialize
# the configuration object to child processes.
# - namespace="CELERY" means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object("django.conf:settings", namespace="CELERY")

# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
19 changes: 18 additions & 1 deletion application/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,21 @@

STATIC_URL = "/static/"

STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"

# Celery configuration

CELERY_BROKER_URL = os.environ.get("BROKER_URL")

CELERY_RESULT_BACKEND = CELERY_BROKER_URL

CELERY_BEAT_SCHEDULE = {
#
# A list of scheduled tasks
#
# "your-complex-task-name": {
# "task": "task_function_name",
# "schedule": 60.0,
# }
#
}

0 comments on commit 58c0bad

Please sign in to comment.