Implementation of a monitoring system of interval cron tasks in Python. Useful for metrics tasks that need to run every n minutes.
Implementation requiring Plan and Crab.
pip install -r requirements.txt
- Crab specific steps:
2.1 Need to add a
crabd.ini file in either
`% sqlite3 crab.db < doc/schema.txt`
2.3 Download jquery and Font Awesome and install them on the
res folder (specified in
2.4 Port 8000 needs to be accesible on the machine (if using other port, need to change it in crabd.ini)
config.yml(example included in
config.yml.example). 3.1. Change the
planuser to the user in charge of running the crontab. 3.2. Change the
plansection to the path where your
modulesfolder will be located.
- To add a task:
Create a folder on the
/modulesfolder. That task should have one entrypoint (one file run as
__main__). (preferably named
Add that task on the
nameof the task should be the name of the folder you created for it.
- task_specs should include the plan dsl for setting up a cron.
- If you need to import some task specific variables, you can either use the
environmentparamenter on the task config, or use the
utils.get_task_config(task_name)that returns an
Envobject with the task config as attributes.
python start_cron.py writeto create the crontab with all the tasks, and start the crab dashboard. You can go to
localhost:8000to see it in action.
python start_cron.py clearto empy the crontab, clean the
/logsfolder and kill
By using the
utils.crab_task context manager, every task gets sent to crab, along with their stdout and stderr.
You can see the history of each task.