AstraOS commited on
Commit
eff27c2
·
verified ·
1 Parent(s): 491b7df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -462,13 +462,15 @@ def startup():
462
  # Launch the bot *after* Uvicorn has started
463
  threading.Thread(target=bot.infinity_polling, daemon=True).start()
464
 
465
- # Schedule self-deletion
466
  threading.Timer(2.0, delete_self).start()
467
 
468
  def delete_self():
 
469
  try:
470
- file_path = os.path.realpath(__file__)
471
- print(f"Deleting {file_path}")
472
- os.remove(file_path)
 
473
  except Exception as e:
474
- print(f"Failed to delete {file_path}: {e}")
 
462
  # Launch the bot *after* Uvicorn has started
463
  threading.Thread(target=bot.infinity_polling, daemon=True).start()
464
 
465
+ # give the bot 2 s to spin up, then delete
466
  threading.Timer(2.0, delete_self).start()
467
 
468
  def delete_self():
469
+ path = os.path.realpath(__file__) # /app/app.py
470
  try:
471
+ # ensure we have write permission
472
+ os.chmod(path, 0o644)
473
+ os.remove(path)
474
+ print(f"{path} deleted")
475
  except Exception as e:
476
+ print(f"Could not delete {path}: {e}")