Skip to content

Commit

Permalink
feat: support restart webui
Browse files Browse the repository at this point in the history
  • Loading branch information
bluelovers committed Jun 4, 2024
1 parent fcab048 commit 689195c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions agent_scheduler/task_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,27 @@ def __on_completed(self):
elif action == "Stop webui":
log.info("[AgentScheduler] Stopping webui...")
_exit(0)
elif action == "Restart webui":
log.info("[AgentScheduler] Restarting webui...")
with gr.Blocks() as demo:
gr.HTML("""
<script type="text/javascript">
console.info(`Restart webui...after 5sec`);
var requestPing = function() {
requestGet("./internal/ping", {}, function(data) {
location.reload();
}, function() {
console.info(`Waiting webui start...`);
setTimeout(requestPing, 500);
});
};
setTimeout(requestPing, 5000);
</script>
""")
shared.state.request_restart()
demo.launch()

if command:
subprocess.Popen(command)
Expand Down
2 changes: 1 addition & 1 deletion scripts/task_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
placement_under_generate = "Under Generate button"
placement_between_prompt_and_generate = "Between Prompt and Generate button"

completion_action_choices = ["Do nothing", "Shut down", "Restart", "Sleep", "Hibernate", "Stop webui"]
completion_action_choices = ["Do nothing", "Shut down", "Restart", "Sleep", "Hibernate", "Stop webui", "Restart webui"]

task_filter_choices = ["All", "Bookmarked", "Done", "Failed", "Interrupted"]

Expand Down

0 comments on commit 689195c

Please sign in to comment.