AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(server): Ensure nameserver is started before other processes (#7788)
Aarushi407cf858e76e
diff --git a/rnd/autogpt_server/autogpt_server/app.py b/rnd/autogpt_server/autogpt_server/app.pyindex 57141bfb35..8b67a9e4d3 100644--- a/rnd/autogpt_server/autogpt_server/app.py+++ b/rnd/autogpt_server/autogpt_server/app.py@@ -1,5 +1,8 @@from multiprocessing import freeze_support, set_start_method+import Pyro5.api as pyro+from tenacity import retry, stop_after_attempt, wait_exponential+from autogpt_server.executor import ExecutionManager, ExecutionSchedulerfrom autogpt_server.server import AgentServerfrom autogpt_server.util.process import AppProcess@@ -13,13 +16,28 @@ def get_config_and_secrets():return settings+@retry(stop=stop_after_attempt(30), wait=wait_exponential(multiplier=1, min=1, max=30))+def wait_for_nameserver():+ pyro.locate_ns(host="localhost", port=9090)+ print("NameServer is ready")++def run_processes(processes: list[AppProcess], **kwargs):"""Execute all processes in the app. The last process is run in the foreground."""try:- for process in processes[:-1]:+ # Start NameServer first+ processes[0].start(background=True, **kwargs)++ # Wait for NameServer to be ready+ wait_for_nameserver()++ # Start other processes+ for process in processes[1:-1]:process.start(background=True, **kwargs)++ # Run the last process in the foregroundprocesses[-1].start(background=False, **kwargs)except Exception as e:for process in processes: