mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Co-authored-by: Xingyao Wang <xingyao6@illinois.edu> Co-authored-by: Xingyao Wang <xingyao@all-hands.dev> Co-authored-by: Graham Neubig <neubig@gmail.com>
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
def get_remote_startup_command(
|
|
port: int,
|
|
sandbox_workspace_dir: str,
|
|
username: str,
|
|
user_id: int,
|
|
plugin_args: list[str],
|
|
browsergym_args: list[str],
|
|
is_root: bool = False,
|
|
):
|
|
base_cmd = [
|
|
'/openhands/micromamba/bin/micromamba',
|
|
'run',
|
|
'-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,
|
|
]
|
|
|
|
if is_root:
|
|
# If running as root, set highest priority and lowest OOM score
|
|
cmd_str = ' '.join(base_cmd)
|
|
return [
|
|
'nice',
|
|
'-n',
|
|
'-20', # Highest priority
|
|
'sh',
|
|
'-c',
|
|
f'echo -1000 > /proc/self/oom_score_adj && exec {cmd_str}',
|
|
]
|
|
else:
|
|
# If not root, run with normal priority
|
|
return base_cmd
|