restart.py 572 B

1234567891011121314151617181920212223
  1. import os
  2. from pathlib import Path
  3. from modules.paths_internal import script_path
  4. def is_restartable() -> bool:
  5. """
  6. Return True if the webui is restartable (i.e. there is something watching to restart it with)
  7. """
  8. return bool(os.environ.get('SD_WEBUI_RESTART'))
  9. def restart_program() -> None:
  10. """creates file tmp/restart and immediately stops the process, which webui.bat/webui.sh interpret as a command to start webui again"""
  11. (Path(script_path) / "tmp" / "restart").touch()
  12. stop_program()
  13. def stop_program() -> None:
  14. os._exit(0)