golemfactory / dapp-runner

GNU Lesser General Public License v3.0
5 stars 6 forks source link

Binding http_proxy to an already bound port will not print the local_proxy_url #103

Open cryptobench opened 1 year ago

cryptobench commented 1 year ago

We found that local_proxy_url was never printed on the Golem Portal and I investigated this and its because the dapp wanted to spin up on the local port 80, but on the golem portal that port is occupied by the nginx server.

        http_proxy:
            ports:
                - "80:80"

What's interesting is that if you use CTRL + C after the service has started (but never printed), then the absolutely last line after shutdown is the error message about the port being bound already.

[2023-03-23T10:31:07.733+0100 INFO dapp_runner.runner] Application started.
^C[2023-03-23T10:31:48.263+0100 INFO dapp_runner.runner] Shutting down ...
[2023-03-23T10:31:48.264+0100 INFO dapp_runner.runner] Stopping the application...
{"nodes": {"backend": {"0": "stopping"}, "frontend": {"0": "stopping"}}, "app": "stopping", "timestamp": "2023-03-23T09:31:48.269665+00:00"}
{"nodes": {"backend": {"0": "stopping"}, "frontend": {"0": "stopping"}}, "app": "stopping", "timestamp": "2023-03-23T09:31:48.269691+00:00"}
[2023-03-23T10:31:48.275+0100 INFO yapapi.network] Removed network: Network { id: 565f31735d8f4213ae91bf6fc253f712, ip: 192.168.1.0, mask: 255.255.255.0}
[2023-03-23T10:31:48.440+0100 INFO yapapi.services.service_runner] <DappService-frontend terminated on sharkoon_378_2.h [ 0xe244f969c1e01bb034dd229aa1be6def50bb3d2d ] @ 192.168.1.4> decommissioned
[2023-03-23T10:31:48.448+0100 INFO yapapi.services.service_runner] <DappService-backend terminated on golem2004_2.h [ 0x79bcfdc92af492c9b15ce9f690c3ccae53437179 ] @ 192.168.1.3> decommissioned
{"nodes": {"backend": {"0": "terminated"}, "frontend": {"0": "terminated"}}, "app": "terminated", "timestamp": "2023-03-23T09:31:48.781351+00:00"}
{"nodes": {"backend": {"0": "terminated"}, "frontend": {"0": "terminated"}}, "app": "terminated", "timestamp": "2023-03-23T09:31:48.845564+00:00"}
[2023-03-23T10:31:49.354+0100 INFO yapapi.summary] [Job 2] Job finished in 75.7s
[2023-03-23T10:31:49.354+0100 INFO yapapi.summary] [Job 2] Negotiated 1 agreements with 1 provider
[2023-03-23T10:31:49.780+0100 INFO yapapi.summary] [Job 1] Terminated agreement with golem2004_2.h
[2023-03-23T10:31:49.851+0100 INFO yapapi.summary] [Job 2] Accepted invoice from 'sharkoon_378_2.h', amount: 0.002572345152250000
[2023-03-23T10:31:49.935+0100 INFO yapapi.summary] [Job 1] Accepted invoice from 'golem2004_2.h', amount: 0.005725104028000001
[2023-03-23T10:31:50.293+0100 INFO yapapi.summary] [Job 1] Agreement proposed to provider 'sharkoon_379_2.h' (0xf6def06a40b5d2adf3e42141448786f0c2e07f37)
[2023-03-23T10:31:50.516+0100 INFO yapapi.summary] [Job 1] Agreement confirmed by provider 'sharkoon_379_2.h'
[2023-03-23T10:31:51.349+0100 WARNING yapapi.summary] [Job 1] Worker for provider 'sharkoon_379_2.h' failed; reason: Can't add_node when in removed.
[2023-03-23T10:31:53.014+0100 INFO yapapi.executor] Golem is shutting down...
[2023-03-23T10:31:53.015+0100 INFO yapapi.summary] [Job 1] Job finished in 135.4s
[2023-03-23T10:31:53.015+0100 INFO yapapi.summary] [Job 1] Negotiated 2 agreements with 2 providers
[2023-03-23T10:31:53.015+0100 INFO yapapi.summary] [Job 1] Provider 'sharkoon_379_2.h' did not compute any tasks
[2023-03-23T10:31:53.015+0100 INFO yapapi.summary] [Job 1] Activity failed 1 time on provider 'sharkoon_379_2.h'
[2023-03-23T10:31:53.016+0100 INFO yapapi.executor] All jobs have finished
[2023-03-23T10:31:53.016+0100 INFO yapapi.executor] Waiting for Golem services to finish...
[2023-03-23T10:31:53.031+0100 INFO yapapi.summary] Total cost: 0.008297449180250001
[2023-03-23T10:31:53.031+0100 INFO yapapi.summary] Golem engine has shut down
Traceback (most recent call last):
  File "/Users/golemgrid/.pyenv/versions/3.10.0/bin/dapp-runner", line 8, in <module>
    sys.exit(_cli())
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/site-packages/dapp_runner/__main__.py", line 132, in start
    start_runner(config_dict, dapp_dict, log_level=log_level, **kwargs)
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/site-packages/dapp_runner/runner/__init__.py", line 151, in start_runner
    loop.run_until_complete(cancel_and_await_tasks(task))
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
    return future.result()
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/site-packages/dapp_runner/_util.py", line 96, in cancel_and_await_tasks
    await task
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/site-packages/dapp_runner/runner/__init__.py", line 102, in _run_app
    await r.stop()
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/site-packages/dapp_runner/_util.py", line 96, in cancel_and_await_tasks
    await task
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/site-packages/dapp_runner/runner/runner.py", line 98, in _start_local_http_proxy
    await proxy.run()
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/site-packages/yapapi/contrib/service/http_proxy.py", line 275, in run
    await site.start()
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/site-packages/aiohttp/web_runner.py", line 121, in start
    self._server = await loop.create_server(
  File "/Users/golemgrid/.pyenv/versions/3.10.0/lib/python3.10/asyncio/base_events.py", line 1493, in create_server
    raise OSError(err.errno, 'error while attempting '
OSError: [Errno 48] error while attempting to bind on address ('0.0.0.0', 80): address already in use