Reputation: 135
Using Google App Engine Standard Python 2.7, I have a path in my dispatch.yaml to specify all urls of type "*/flex/*" to route to the flex service.
dispatch.yaml dispatch:
- url: '*/flex/*'
module: flex
The flex environment is a custom python 3.7 runtime which is executed normally using:
python dev_appserver.py flex.yaml --custom_entrypoint="docker run -p 9090:8080 flex_app"
.
With other services in my environment, I attempt to launch a dev environment with the command:
python dev_appserver.py dispatch.yaml default.yaml sync.yaml task.yaml flex.yaml --custom_entrypoint="docker run -p 9090:8080 flex_app" --port=8080 --skip_sdk_update_check"
However, when this starts, it starts assigning local ip addresses to each service when I need the flex service to be accessed from port 9090.
Example server output:
INFO devappserver2.py:278] Skipping SDK update check.
INFO dispatcher.py:223] Starting dispatcher running at: http://0.0.0.0:8080
INFO dispatcher.py:256] Starting module "default" running at: http://0.0.0.0:8081
INFO dispatcher.py:256] Starting module "sync" running at: http://0.0.0.0:8082
INFO dispatcher.py:256] Starting module "task" running at: http://0.0.0.0:8083
INFO dispatcher.py:256] Starting module "flex" running at: http://0.0.0.0:8084
I am able to successfully access the flex app if I hit the URL localhost:9090. However, if I access localhost:8084 or localhost:8080/flex/, I receive the error:
503 - This request has timed out.
The server logs reflect this but do not show an actual error:
INFO module.py:861] flex: "GET / HTTP/1.1" 503 59
Is it possible to dispatch urls from GAE Standard Environments to a Flex environment and have it route from its designated port to the desired port needed? I would think this is possible as Google App Engine's Doc specifies it is possible to mix the environments together. I've also attempted to solve this by forcing docker to run on port 8084 but the ports can't be shared.
Upvotes: 1
Views: 135
Reputation: 135
Found this by looking in dev_appserver.py --help
. Turns out the answer to this was simply changing the custom_entrypoint to the command docker run -p {port}:8080 flex_app
and this would automatically forward GAE's randomly assigned port to the docker instance.
--custom_entrypoint CUSTOM_ENTRYPOINT
specify an entrypoint for custom runtime modules. This
is required when such modules are present. Include
"{port}" in the string (without quotes) to pass the
port number in as an argument.
Upvotes: 1
Reputation: 39824
The development server can only be used for the 1st generation standard environment apps, it doesn't work with flexible apps, see How to use Python 3 with Google App Engine's Local Development Server.
I think your attempt just ends up running the service as a standard environment one, not a flexible one (chances of it running correctly are pretty slim).
To run correctly you'd have to drop it from the local dev_server execution. Cross-service links to the flexible service would need some sort of hack locally to use the 9090 port (via env variables or simply some hardcoded values), you won't be able to use the dispatch.yaml
routing in this case (since the local devserver won't know about the flexible service's existence).
Upvotes: 0