panodata / imagecast

Imagecast is like ImageMagick but for Pythonistas. Optionally provides its features via HTTP API.
GNU Affero General Public License v3.0
1 stars 0 forks source link

Internal service error after update to version 0.7.0 #55

Open amotl opened 3 months ago

amotl commented 3 months ago

Problem

Variants of ...

BrowserType.launch: Executable doesn't exist at /usr/sbin/.cache/ms-playwright/firefox-1447/firefox/firefox
BrowserType.launch: Executable doesn't exist at /home/workbench/.cache/ms-playwright/firefox-1447/firefox/firefox
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
    return await self.app(scope, receive, send)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/starlette/routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/starlette/routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/starlette/routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/starlette/routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/starlette/routing.py", line 72, in app
    response = await func(request)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/fastapi/routing.py", line 278, in app
    raw_response = await run_endpoint_function(
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/fastapi/routing.py", line 193, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/starlette/concurrency.py", line 42, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/anyio/to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 2177, in run_sync_in_worker_thread
    return await future
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 859, in run
    result = context.run(func, *args)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/imagecast/api.py", line 75, in index
    ie = process(options)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/imagecast/core.py", line 108, in process
    ie.acquire(options.uri, options.element)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/imagecast/core.py", line 33, in acquire
    self.data = self.capture(uri, dom_selector)
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/imagecast/core.py", line 39, in capture
    browser = p.firefox.launch()
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/playwright/sync_api/_generated.py", line 13914, in launch
    self._sync(
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/playwright/_impl/_sync_base.py", line 115, in _sync
    return task.result()
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/playwright/_impl/_browser_type.py", line 94, in launch
    Browser, from_channel(await self._channel.send("launch", params))
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 59, in send
    return await self._connection.wrap_api_call(
  File "/opt/imagecast/.venv/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 513, in wrap_api_call
    raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
playwright._impl._errors.Error: BrowserType.launch: Executable doesn't exist at /home/workbench/.cache/ms-playwright/firefox-1447/firefox/firefox
╔════════════════════════════════════════════════════════════╗
║ Looks like Playwright was just installed or updated.       ║
║ Please run the following command to download new browsers: ║
║                                                            ║
║     playwright install                                     ║
║                                                            ║
║ <3 Playwright Team                                         ║
╚════════════════════════════════════════════════════════════╝
amotl commented 3 months ago

Solution

Install/update the Firefox installation of Playwright.

su - workbench
source /opt/imagecast/.venv/bin/activate
playwright install firefox

Also updated the systemd unit file, changing User/Group to workbench, and adding StandardError as well as StandardOutput, in order to support debugging error output using journalctl -u imagecast -f.

[Service]
User=workbench
Group=workbench
LimitNOFILE=65536
ExecStart=/opt/imagecast/.venv/bin/imagecast service --listen=localhost:24630 --allowed-hosts=swarm.hiveeyes.org,weather.hiveeyes.org,unsplash.com
StandardError=journal
StandardOutput=journal
KillMode=control-group
Restart=on-failure