Skip to content

Commit

Permalink
Remove directories leftover from improper shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyHowell authored and tornaria committed Feb 25, 2023
1 parent 8f5bbd2 commit 2b155c7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/bin/sage-cleaner
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ def cleanup():

return len(pid_list)

def cleanup_cruft():
""" remove directories leftover from improper shutdown """
tmp_dirs = os.listdir(SAGE_TMP_ROOT)
for dir_entry in tmp_dirs:
baddir = os.path.join(SAGE_TMP_ROOT, dir_entry)
if os.path.isdir(baddir):
logger.warning('Removing old directory %s from SAGE_TMP_ROOT', baddir)
rm_rf(baddir)

def kill_spawned_jobs(jobfile, parent_pid):
logger.info("Killing %s's spawned jobs", parent_pid)
killed_them_all = True
Expand Down Expand Up @@ -193,6 +202,7 @@ if __name__ == '__main__':
setup_daemon()
fix_old_mistakes()
logger.info("Starting sage-cleaner with PID %s", os.getpid())
cleanup_cruft()

if len(sys.argv) > 1:
wait = int(sys.argv[1])
Expand Down

0 comments on commit 2b155c7

Please sign in to comment.