mirror of
https://github.com/ansible/awx.git
synced 2026-05-06 08:57:35 -02:30
Implement a stdout tmp cleanup task
* Cleans up stdout tempfiles generated for download * Runs every 3 hours, cleans up files older than 1 day
This commit is contained in:
@@ -114,6 +114,17 @@ def tower_periodic_scheduler(self):
|
|||||||
new_unified_job.socketio_emit_status("failed")
|
new_unified_job.socketio_emit_status("failed")
|
||||||
emit_websocket_notification('/socket.io/schedules', 'schedule_changed', dict(id=schedule.id))
|
emit_websocket_notification('/socket.io/schedules', 'schedule_changed', dict(id=schedule.id))
|
||||||
|
|
||||||
|
@task(bind=True)
|
||||||
|
def clean_stdout_tempfiles(self):
|
||||||
|
nowtime = time.time()
|
||||||
|
removed = 0
|
||||||
|
for this_file in os.listdir(settings.STDOUT_TEMP_DIR):
|
||||||
|
this_file = os.path.join(settings.STDOUT_TEMP_DIR, this_file)
|
||||||
|
if "towerjob" in this_file and os.stat(this_file).st_mtime < nowtime - 86400:
|
||||||
|
os.remove(this_file)
|
||||||
|
removed += 1
|
||||||
|
print("Removed %d files" % removed)
|
||||||
|
|
||||||
@task()
|
@task()
|
||||||
def notify_task_runner(metadata_dict):
|
def notify_task_runner(metadata_dict):
|
||||||
"""Add the given task into the Tower task manager's queue, to be consumed
|
"""Add the given task into the Tower task manager's queue, to be consumed
|
||||||
|
|||||||
@@ -303,6 +303,10 @@ CELERYBEAT_SCHEDULE = {
|
|||||||
'task': 'awx.main.tasks.tower_periodic_scheduler',
|
'task': 'awx.main.tasks.tower_periodic_scheduler',
|
||||||
'schedule': timedelta(seconds=30)
|
'schedule': timedelta(seconds=30)
|
||||||
},
|
},
|
||||||
|
'job_stdout_cleanup': {
|
||||||
|
'task': 'awx.main.tasks.clean_stdout_tempfiles',
|
||||||
|
'schedule': timedelta(hours=3)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
# Any ANSIBLE_* settings will be passed to the subprocess environment by the
|
# Any ANSIBLE_* settings will be passed to the subprocess environment by the
|
||||||
|
|||||||
Reference in New Issue
Block a user