我已经创建了一个 Rasa Chatbot,可以询问用户信息并将其存储在 postgres 数据库中。 在本地运行正常。 我一直在尝试在 Docker 中实现它,但是无法工作。我是 Docker 的新手,请有谁能帮帮我。 提前感谢。
docker-compose.yml
错误:
docker-compose.yml
version: "3.0"
services:
rasa:
container_name: rasa
image: rasa/rasa:2.8.1-full
ports:
- 5005:5005
volumes:
- ./:/app
command:
- run
- -m
- models
- --enable-api
- --cors
- "*"
depends_on:
- action-server1
- db
action-server1:
container_name: "action-server1"
build:
context: actions
volumes:
- ./actions:/app/actions
ports:
- "5055:5055"
networks:
- shan_network
db:
image: "postgres"
environment:
POSTGRESQL_USERNAME: "postgres"
POSTGRESQL_PASSWORD: ""
POSTGRESQL_DATABASE: "postgres"
POSTGRES_HOST_AUTH_METHOD: "trust"
volumes:
- db-data:/var/lib/postgresql/data
ports:
- "5432:5432"
volumes:
db-data:
日志:所有服务都在日志中运行,我还检查了docker,postgresql也在运行。
db_1 |
db_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
db_1 |
db_1 | 2021-08-05 08:21:45.685 UTC [1] LOG: starting PostgreSQL 13.3 (Debian 13.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debia
n 8.3.0-6) 8.3.0, 64-bit
db_1 | 2021-08-05 08:21:45.686 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2021-08-05 08:21:45.686 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2021-08-05 08:21:45.699 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2021-08-05 08:21:45.712 UTC [26] LOG: database system was shut down at 2021-08-05 08:21:25 UTC
db_1 | 2021-08-05 08:21:45.722 UTC [1] LOG: database system is ready to accept connections
错误:
action-server1 | warnings.warn(
action-server1 | Exception occurred while handling uri: 'http://action-server1:5055/webhook'
action-server1 | Traceback (most recent call last):
action-server1 | File "/opt/venv/lib/python3.8/site-packages/sanic/app.py", line 973, in handle_request
action-server1 | response = await response
action-server1 | File "/opt/venv/lib/python3.8/site-packages/rasa_sdk/endpoint.py", line 104, in webhook
action-server1 | result = await executor.run(action_call)
action-server1 | File "/opt/venv/lib/python3.8/site-packages/rasa_sdk/executor.py", line 398, in run
action-server1 | action(dispatcher, tracker, domain)
**action-server1 | File "/app/actions/actions.py", line 148, in run
action-server1 | connection = psycopg2.connect(database="postgres", user='postgres', password='password',port='5432'
action-server1 | File "/opt/venv/lib/python3.8/site-packages/psycopg2/__init__.py", line 122, in connect
action-server1 | conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
action-server1 | psycopg2.OperationalError: could not connect to server: No such file or directory
action-server1 | Is the server running locally and accepting
action-server1 | connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?**
rasa | 2021-08-05 08:25:13 ERROR rasa.core.processor - Encountered an exception while running action 'action_save'.Bot will continue, but
the actions events are lost. Please check the logs of your action server for more information.
rasa | Traceback (most recent call last):
rasa | File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 685, in run
rasa | response = await self.action_endpoint.request(
rasa | File "/opt/venv/lib/python3.8/site-packages/rasa/utils/endpoints.py", line 172, in request
rasa | raise ClientResponseError(
rasa | rasa.utils.endpoints.ClientResponseError: 500, Internal Server Error, body='b'<!DOCTYPE html><meta charset=UTF-8><title>500 \xe2\x80\x9
4 Internal Server Error</title><style>html { font-family: sans-serif }</style>\n<h1>\xe2\x9a\xa0\xef\xb8\x8f 500 \xe2\x80\x94 Internal Server Error</h1><p>
The server encountered an internal error and cannot complete your request.\n''
rasa |
rasa | The above exception was the direct cause of the following exception:
rasa |
rasa | Traceback (most recent call last):
rasa | File "/opt/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 772, in _run_action
rasa | events = await action.run(
rasa | File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 709, in run
rasa | raise RasaException("Failed to execute custom action.") from e
rasa | rasa.shared.exceptions.RasaException: Failed to execute custom action.
psycopg2
查询,或者使用你的应用程序。 - anemyte