in docker/serverless/env_start_proxy.py [0:0]
def gen_args(cmd):
ARGS = [
cmd,
"/apiproxy/start_proxy.py",
"--on_serverless"
]
# Uncaught AssertionError;
# if no port, we can't serve a nice error handler. Crash instead.
assert_env_var("PORT")
ARGS.append("--http_port={}".format(os.environ["PORT"]))
if "ENDPOINTS_SERVICE_PATH" in os.environ:
ARGS.extend(
[
"--rollout_strategy=fixed",
"--service_json_path={}".format(os.environ["ENDPOINTS_SERVICE_PATH"]),
]
)
else:
try:
assert_env_var(
"ENDPOINTS_SERVICE_NAME",
MISSING_SERVICE_CONFIG_ERROR
)
except AssertionError as error:
serve_warning_msg(str(error))
ARGS.append("--service={}".format(os.environ["ENDPOINTS_SERVICE_NAME"]))
if "ENDPOINTS_SERVICE_VERSION" in os.environ:
ARGS.extend(
[
"--rollout_strategy=fixed",
"--version={}".format(os.environ["ENDPOINTS_SERVICE_VERSION"]),
]
)
else:
ARGS.append("--rollout_strategy=managed")
if "ESPv2_ARGS" in os.environ:
# By default, ESPv2_ARGS is comma-separated.
# But if a comma needs to appear within an arg, there is an alternative
# syntax: Pick a replacement delimiter, specify it at the beginning of the
# string between two caret (^) symbols, and use it within the arg string.
# Example:
# ^++^--cors_allow_methods="GET,POST,PUT,OPTIONS"++--cors_allow_credentials
arg_value = os.environ["ESPv2_ARGS"]
delim = ","
if arg_value.startswith("^") and "^" in arg_value[1:]:
delim, arg_value = arg_value[1:].split("^", 1)
if not delim:
serve_error_msg(MALFORMED_ESPv2_ARGS_ERROR)
ARGS.extend(arg_value.split(delim))
return ARGS