Skip to content

Commit

Permalink
fix bug alloc server
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-x-c committed Sep 5, 2024
1 parent 145c4ba commit 5d3bd26
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/agentscope/studio/_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,18 @@ def _alloc_server() -> Response:
# TODO: allocate based on server's cpu and memory usage
# currently random select a server
servers = _ServerTable.query.all()
if len(servers) == 0:
return jsonify({"status": "fail"})
server = choice(servers)
return jsonify(
{
"host": server.host,
"port": server.port,
},
)
if RpcClient(host=server.host, port=server.port).is_alive():
return jsonify(
{
"host": server.host,
"port": server.port,
},
)
else:
return jsonify({"status": "fail"})


@_app.route("/api/messages/push", methods=["POST"])
Expand Down

0 comments on commit 5d3bd26

Please sign in to comment.