mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
new middleware handler and ability to restart server on-the-fly
This commit is contained in:
@@ -632,6 +632,8 @@ def reload_gradio_theme(theme_name=None):
|
||||
print("Theme download error accessing HuggingFace")
|
||||
gradio_theme = gr.themes.Default()
|
||||
print(f'Loading theme: {theme_name}')
|
||||
if demo is not None:
|
||||
demo.close()
|
||||
|
||||
|
||||
class TotalTQDM:
|
||||
@@ -673,6 +675,19 @@ mem_mon = modules.memmon.MemUsageMonitor("MemMon", device, opts)
|
||||
mem_mon.start()
|
||||
|
||||
|
||||
def restart_server():
|
||||
if demo is None:
|
||||
return
|
||||
try:
|
||||
demo.server.should_exit = True
|
||||
demo.server.force_exit = True
|
||||
demo.close(verbose=False)
|
||||
demo.server.close()
|
||||
except:
|
||||
pass
|
||||
print('Server shutdown')
|
||||
|
||||
|
||||
def listfiles(dirname):
|
||||
filenames = [os.path.join(dirname, x) for x in sorted(os.listdir(dirname), key=str.lower) if not x.startswith(".")]
|
||||
return [file for file in filenames if os.path.isfile(file)]
|
||||
|
||||
Reference in New Issue
Block a user