Scheduled tasks are run using celery, but can be set up using the Django admin interface at at http://127.0.0.1:8000/admin.
When setting up a new server you need to:
- Run the "calculations.initialModelSetUp" task once. (TODO: check how to do that with admin interface).
- Set up daily scheduled tasks.
- Go to http://127.0.0.1:8000/admin and log in as an admin user.
- Go to Periodic tasks and click "Add".
- Give the task a name, e.g. "Initial setup".
- Under Task (registered) choose "calculations.initialModelSetUp".
- Next to Clocked Schedule click the + button.
- Choose the time to start the job (use the Today and Now links to start immediately).
- Click Save.
The initial model should run. You can check the celery logs for details.
The following tasks should be scheduled daily, allowing time for each task to complete before running the next. (The time needed will depend on the server the code is running on: set up each task and see how long it takes before setting up the next.)
- calculations.dailyModelUpdate
- Run flood model (depends on dailyModelUpdate)
- Calculate risk percentages (depends on 'Run flood model', which has many subtasks)
- Send all alerts (depends on 'Run flood model', which has many subtasks)
To schedule each task:
- Go to http://127.0.0.1:8000/admin and log in as an admin user.
- Go to Periodic tasks and click "Add".
- Give the task a name.
- Choose the job to run (e.g. 'Run flood model').
- Next to Crontab Schedule click the + button.
- Fill in the values for the crontab, eg. to run every day at 2am, choose minutes 0, hour 2, and leave the rest as *. Click Save.
- Choose the start datetime (use the Today and Now links to start immediately).
- Click Save.
Repeat for the other tasks.