Skip to content

Commit

Permalink
add possibility to pass envs
Browse files Browse the repository at this point in the history
  • Loading branch information
MP91 committed Jun 27, 2024
1 parent 968564b commit a2ae864
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions runtime_local/src/run-vehicle-app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
from velocitas_lib.services import get_service_port


def run_app(
executable_path: str,
args: list[str],
):
def run_app(executable_path: str, args: list[str], envs: list[str]):
program_args = [executable_path, *args]

if get_middleware_type() == MiddlewareType.NATIVE:
Expand All @@ -36,6 +33,8 @@ def run_app(
"SDV_VEHICLEDATABROKER_ADDRESS": f"{vdb_address}:{vdb_port}",
"SDV_MQTT_ADDRESS": f"{mqtt_address}:{mqtt_port}",
}
middleware_config.update({env.split("=")[0]: env.split("=")[1] for env in envs})

subprocess.check_call(program_args, env=middleware_config)
else:
raise NotImplementedError("Unsupported middleware type!")
Expand All @@ -49,9 +48,9 @@ def run_app(
"executable_path", type=str, help="Path to the executable to be invoked."
)
parser.add_argument("app_args", nargs="*")
parser.add_argument(
"-e", "--env", help="Environment variable to pass to the app.", action="append"
)

args = parser.parse_args()
run_app(
args.executable_path,
args.app_args,
)
run_app(args.executable_path, args.app_args, args.env)

0 comments on commit a2ae864

Please sign in to comment.