celery: Add scheduled task update_beacon_receiver_distance

Celery beat is used to call update_beacon_receiver_distance_all
every five minutes.
The time interval is configurable by adjusting the configuration file.
pull/35/head
Fabian P. Schmidt 2016-01-29 05:33:59 +01:00
rodzic ae3788764d
commit 31b2aaddda
3 zmienionych plików z 22 dodań i 6 usunięć

Wyświetl plik

@ -81,18 +81,25 @@ To schedule tasks like takeoff/landing-detection (`logbook.compute`),
The following scripts run in the foreground and should be deamonized
(eg. use [supervisord](http://supervisord.org/)).
- start aprs client
- Start the aprs client
```
./manage.py gateway.run
```
- start task server (make sure redis is up and running)
- Start a task server (make sure redis is up and running)
```
celery -A ogn.collect worker -l info
```
- Start the task scheduler (make sure a task server is up and running)
```
celery -A ogn.collect beat -l info
```
To load a custom configuration, create a file `myconfig.py` (see [config/default.py](config/default.py))
and set the environment variable `OGN_CONFIG_MODULE` accordingly.
@ -138,7 +145,7 @@ available commands:
Only the command `logbook.compute` requires a running task server (celery) at the moment.
### Scheduled tasks
### Available tasks
- ogn.collect.database
- `import_ddb` - Import registered devices from the ddb
- `import_file` - Import registered devices from a local file

Wyświetl plik

@ -2,3 +2,15 @@ SQLALCHEMY_DATABASE_URI = 'sqlite:///beacons.db'
BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
from datetime import timedelta
CELERYBEAT_SCHEDULE = {
'update-receiver-distance': {
'task': 'ogn.collect.heatmap.update_beacon_receiver_distance_all',
'schedule': timedelta(minutes=5),
},
}
CELERY_TIMEZONE = 'UTC'

Wyświetl plik

@ -2,7 +2,6 @@ import logging
from ogn.gateway.client import ognGateway
from ogn.commands.dbutils import session
from ogn.collect.heatmap import update_beacon_receiver_distance
from manager import Manager
@ -35,8 +34,6 @@ def run(aprs_user='anon-dev', logfile='main.log', loglevel='INFO'):
gateway.connect()
def process_beacon(beacon):
if isinstance(beacon, ReceiverBeacon):
update_beacon_receiver_distance(beacon.name)
session.add(beacon)
session.commit()