-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from NIAEFEUP/sqlite-setup
Sqlite setup
- Loading branch information
Showing
9 changed files
with
73 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ djangorestframework==3.11.0 | |
pytz==2021.3 | ||
sqlparse==0.4.2 | ||
mysqlclient==1.4.6 | ||
celery==5.2.7 | ||
redis==3.5.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from celery import Celery | ||
from celery.schedules import crontab | ||
import os | ||
|
||
app = Celery('tasks', broker="redis://tts-be-redis_service-1:6379") | ||
|
||
# Gets called after celery sets up. Creates a worker that runs the dump_statistics function at midnight and noon everyday | ||
@app.on_after_configure.connect | ||
def setup_periodic_tasks(sender, **kwargs): | ||
sender.add_periodic_task( | ||
crontab(minute='0', hour='0, 12'), | ||
dump_statistics.s(), | ||
name='dump statistics' | ||
) | ||
|
||
@app.task | ||
def dump_statistics(): | ||
command = "mysqldump -P {} -h db -u {} -p{} {} statistics > statistics.sql".format( | ||
os.environ["MYSQL_PORT"], | ||
os.environ["MYSQL_USER"], | ||
os.environ["MYSQL_PASSWORD"], | ||
os.environ["MYSQL_DATABASE"]) | ||
os.system(command) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters