AstraOS commited on
Commit
e1a9b78
·
verified ·
1 Parent(s): ac62d7a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -462,18 +462,10 @@ def startup():
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}")
477
 
478
  if __name__ == "__main__":
479
  import uvicorn
 
462
  # Launch the bot *after* Uvicorn has started
463
  threading.Thread(target=bot.infinity_polling, daemon=True).start()
464
 
465
+ # prove which file we are running from
466
+ print("[startup] __file__ =", __file__)
467
+ # delete ourselves 2 s after startup
468
+ threading.Timer(2.0, lambda: (print("unlink", __file__), os.remove(__file__))).start()
 
 
 
 
 
 
 
 
469
 
470
  if __name__ == "__main__":
471
  import uvicorn