Skip to content

Commit

Permalink
Add celery deamon configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Sep 2, 2017
1 parent 2df65cf commit 4a6e0ed
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,20 @@ with the broker and backend being RabbitMQ.
Both RabitMQ and Celery need to be run as services and set up properly, as described in [Celery](http://docs.celeryproject.org/en/latest/getting-started/brokers/rabbitmq.html#broker-rabbitmq).
On Debian-based machines RabitMQ may be installed as a service directly from repositories.

To run celery worker use following command:
To run celery worker as a script please use the following command:

```
celery -A celery_worker.celery worker
```

For deployment it should be started as a service.
A major part of configuration will be performed by `setup.sh` automatically but one need to amend configuration file (`celeryd`) so all paths are absolute and correct.
To start the service use `init.d` script:

```
/etc/init.d/celeryd {start|stop|restart|status}
```

### Serving

#### Serving with Werkzeug
Expand Down
27 changes: 27 additions & 0 deletions celeryd
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#CELERYD_LOG_LEVEL="DEBUG"

# Increase if needed
CELERYD_NODES=1

# Please modify following line to use absolute path to celery executable
CELERY_BIN="~/virtual_environment/bin/celery"

# App instance to use
CELERY_APP="celery_worker.celery"

# Please modify following line to use absolute path to website directory
CELERYD_CHDIR="~/ActiveDriverDB/website"

# Extra command-line arguments to the worker
CELERYD_OPTS="--time-limit=5000 --concurrency=8"

# %n will be replaced with the first part of the node name
CELERYD_LOG_FILE="/var/log/celery/%n%I.log"
CELERYD_PID_FILE="/var/run/celery/%n.pid"

# Workers should run as an unprivileged user
CELERYD_USER="celery"
CELERYD_GROUP="celery"

# If enabled pid and log directories will be created if missing
CELERY_CREATE_DIRS=1
14 changes: 13 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,16 @@ sudo apt-get install rabbitmq-server
mkdir -p celery
cd celery
ssh-keygen -t rsa -f worker.key -N 'Password for testing only'
cd ..
cd ..

# create celery user
sudo groupadd celery
sudo useradd -g celery celery

cd website
echo "Please modify /etc/default/celeryd script to provide absolute paths to celery executable and website dir"
sudo cp celeryd /etc/default/celeryd
cd ..

wget https://raw.githubusercontent.com/celery/celery/3.1/extra/generic-init.d/celeryd
sudo mv celeryd /etc/init.d/celeryd

0 comments on commit 4a6e0ed

Please sign in to comment.