mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-09 19:42:44 +00:00
restart
This commit is contained in:
parent
357909c16a
commit
961dbc405a
7 changed files with 104 additions and 21 deletions
|
|
@ -6,6 +6,9 @@ from agent import AgentContext
|
|||
from initialize import initialize
|
||||
from python.helpers.print_style import PrintStyle
|
||||
from python.helpers.errors import format_error
|
||||
from werkzeug.serving import make_server
|
||||
|
||||
|
||||
|
||||
|
||||
class ApiHandler:
|
||||
|
|
|
|||
35
python/helpers/process.py
Normal file
35
python/helpers/process.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import os
|
||||
import sys
|
||||
from python.helpers import runtime
|
||||
|
||||
_server = None
|
||||
|
||||
def set_server(server):
|
||||
global _server
|
||||
_server = server
|
||||
|
||||
def get_server(server):
|
||||
global _server
|
||||
return _server
|
||||
|
||||
def stop_server():
|
||||
global _server
|
||||
if _server:
|
||||
_server.shutdown()
|
||||
_server = None
|
||||
|
||||
def reload():
|
||||
stop_server()
|
||||
if runtime.is_dockerized():
|
||||
exit_process()
|
||||
else:
|
||||
restart_process()
|
||||
|
||||
def restart_process():
|
||||
print("Restarting process...")
|
||||
python = sys.executable
|
||||
os.execv(python, [python] + sys.argv)
|
||||
|
||||
def exit_process():
|
||||
print("Exiting process...")
|
||||
sys.exit(0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue