From d3a6aa29d3bea2b5c184c7534a193094f7e4b949 Mon Sep 17 00:00:00 2001 From: openhands Date: Fri, 22 Nov 2024 15:51:42 +0000 Subject: [PATCH] Set server process to run with highest system priority --- openhands/runtime/utils/command.py | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/openhands/runtime/utils/command.py b/openhands/runtime/utils/command.py index 1617ec20f36f..76dafae0419d 100644 --- a/openhands/runtime/utils/command.py +++ b/openhands/runtime/utils/command.py @@ -6,24 +6,13 @@ def get_remote_startup_command( plugin_args: list[str], browsergym_args: list[str], ): + cmd = f'/openhands/micromamba/bin/micromamba run -n openhands poetry run python -u -m openhands.runtime.action_execution_server {port} --working-dir {sandbox_workspace_dir} {" ".join(plugin_args)} --username {username} --user-id {user_id} {" ".join(browsergym_args)}' return [ - '/openhands/micromamba/bin/micromamba', - 'run', + 'sudo', # Needed for nice -20 + 'nice', '-n', - 'openhands', - 'poetry', - 'run', - 'python', - '-u', - '-m', - 'openhands.runtime.action_execution_server', - str(port), - '--working-dir', - sandbox_workspace_dir, - *plugin_args, - '--username', - username, - '--user-id', - str(user_id), - *browsergym_args, + '-20', # Highest priority + 'sh', + '-c', + f'echo -1000 > /proc/self/oom_score_adj && exec {cmd}' ]