Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more reliable instances startup for the http-proxy example #706

Merged
merged 2 commits into from
Oct 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/http-proxy/http_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ async def request_handler(cluster: Cluster, request: web.Request):

print(f"{TEXT_COLOR_GREEN}local HTTP request: {dict(request.query)}{TEXT_COLOR_DEFAULT}")

instance: HttpService = cluster.instances[request_count % len(cluster.instances)]
instances = [i for i in cluster.instances if i.state == ServiceState.running]
instance: HttpService = instances[request_count % len(instances)]
request_count += 1
response, status = await instance.handle_request(request.path_qs)
return web.Response(text=response, status=status)
Expand Down Expand Up @@ -88,7 +89,7 @@ async def start(self):
yield script

# start the remote HTTP server and give it some content to serve in the `index.html`
script = self._ctx.new_script()
script = self._ctx.new_script(timeout=timedelta(minutes=1))
script.run("/docker-entrypoint.sh")
script.run("/bin/chmod", "a+x", "/")
msg = f"Hello from inside Golem!\n... running on {self.provider_name}"
Expand Down