Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using django-celery-beat to manage periodic tasks #7

Open
ManofWax opened this issue Feb 24, 2023 · 12 comments
Open

Using django-celery-beat to manage periodic tasks #7

ManofWax opened this issue Feb 24, 2023 · 12 comments
Labels
good first issue Good for newcomers

Comments

@ManofWax
Copy link
Contributor

BuffaLogs is based on periodic tasks to detect anomalies. The configs for remote tasks are on django settings file.

We should use django-celery-beat to manage task scheduling configs, in this way we could allow users to edit and change task scheduling in realtime.

This implementation should also take care of loading the default django-celery-beat config when the system starts up the first time. It possible to do so using a django managment command and add it to the docker container start up script

@ManofWax ManofWax added the good first issue Good for newcomers label Feb 24, 2023
@deep-poharkar
Copy link

can i have this? would love to contribute.

@ManofWax
Copy link
Contributor Author

Hi, yeah sure you can implement this.

@0x0elliot
Copy link

0x0elliot commented Apr 5, 2023

seems like no one is helping on this issue. would you mind if i quickly wrap this up?

so would you just like me to add a django celery beat? i do need a function to add in here to run.

@0x0elliot
Copy link

0x0elliot commented Apr 5, 2023

a bit unclear about which function i should plugin, so i am adding the process_logs celery function here.

@ManofWax
Copy link
Contributor Author

ManofWax commented Apr 5, 2023

Hi @0x0elliot, the function you should plugin are process_logs and update_risk_level defined here: https://github.com/certego/BuffaLogs/blob/main/buffalogs/buffalogs/settings/settings.py#L194

Since the django-celery-beat will be used instead of this configuration you should also provide a way to load on the db the cron settings so when someone launches the containers the tasks will be already active.

I'm thinking on putting a command after collectstatics in run.sh: https://github.com/certego/BuffaLogs/blob/main/buffalogs/run.sh that loads the cron setting if the database is empty.

@0x0elliot
Copy link

0x0elliot commented Apr 5, 2023

sorry, i am still catching up here but do you want to call update_risk_level separately in the cron? i see that impossible_travel command also calls it. i think it's better to just call that so i am adding it for now.

@0x0elliot
Copy link

0x0elliot commented Apr 5, 2023

rabbitMQ seems to be breaking for me and not working. weird.

0x0elliot added a commit to 0x0elliot/BuffaLogs that referenced this issue Apr 5, 2023
@Lorygold
Copy link
Collaborator

Lorygold commented Apr 6, 2023

sorry, i am still catching up here but do you want to call update_risk_level separately in the cron? i see that impossible_travel command also calls it. i think it's better to just call that so i am adding it for now.

Hi, the impossible_travel command calls the update_risk_level function in order to check its correct operation manually, in staging.
But to ensure the automatic execution of update_risk_level, it is necessary to insert it in the cron. In this way, this task is performed every 10 minutes.

@Lorygold
Copy link
Collaborator

Lorygold commented Apr 6, 2023

rabbitMQ seems to be breaking for me and not working. weird.

It is still working for me. Can you print here the rabbitMQ logs, please?

@0x0elliot
Copy link

It is still working for me. Can you print here the rabbitMQ logs, please?

don't worry about that. it's just the delay in it starting for the first time when celery tries to connect to it that was bothering me.

@AnkurPrabhu
Copy link

is this issue still open ?

@AnkurPrabhu
Copy link

@ManofWax can i pick this up ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants