我正在Buddy持续集成服务器上运行一个构建,当它到达postgrex/ecto部分时,它在执行mix test
时出现错误:
==> postgrex
Compiling 61 files (.ex)
Compiling lib/postgrex/protocol.ex (it's taking more than 10s)
Compiling lib/postgrex/default_types.ex (it's taking more than 10s)
Generated postgrex app
==> ecto
Compiling 69 files (.ex)
Compiling lib/ecto/query/builder/lock.ex (it's taking more than 10s)
Compiling lib/ecto/repo/queryable.ex (it's taking more than 10s)
Compiling lib/ecto/query/inspect.ex (it's taking more than 10s)
Compiling lib/mix/tasks/ecto.drop.ex (it's taking more than 10s)
Compiling lib/ecto/query/builder/filter.ex (it's taking more than 10s)
Compiling lib/ecto/repo/preloader.ex (it's taking more than 10s)
Compiling lib/mix/tasks/ecto.gen.repo.ex (it's taking more than 10s)
Compiling lib/ecto/adapters/mysql.ex (it's taking more than 10s)
Compiling lib/ecto/schema.ex (it's taking more than 10s)
Compiling lib/ecto/migration/runner.ex (it's taking more than 10s)
Compiling lib/ecto/repo/schema.ex (it's taking more than 10s)
Compiling lib/ecto/embedded.ex (it's taking more than 10s)
Compiling lib/ecto/migration/schema_migration.ex (it's taking more than 10s)
Compiling lib/ecto/query/builder/preload.ex (it's taking more than 10s)
Compiling lib/ecto/query/builder/order_by.ex (it's taking more than 10s)
Compiling lib/ecto/uuid.ex (it's taking more than 10s)
Compiling lib/ecto/type.ex (it's taking more than 10s)
Compiling lib/ecto/association.ex (it's taking more than 10s)
Compiling lib/ecto/adapters/postgres/connection.ex (it's taking more than 10s)
Compiling lib/mix/tasks/ecto.gen.migration.ex (it's taking more than 10s)
Compiling lib/ecto/query/builder/join.ex (it's taking more than 10s)
Compiling lib/ecto/query/planner.ex (it's taking more than 10s)
Compiling lib/ecto/log_entry.ex (it's taking more than 10s)
Compiling lib/ecto/query/builder/select.ex (it's taking more than 10s)
Compiling lib/ecto/query/builder/distinct.ex (it's taking more than 10s)
Compiling lib/ecto/query/builder/limit_offset.ex (it's taking more than 10s)
Compiling lib/ecto/changeset.ex (it's taking more than 10s)
Compiling lib/ecto/query/builder/group_by.ex (it's taking more than 10s)
Compiling lib/ecto/changeset/relation.ex (it's taking more than 10s)
Compiling lib/ecto/multi.ex (it's taking more than 10s)
Compiling lib/ecto.ex (it's taking more than 10s)
Compiling lib/ecto/query/builder.ex (it's taking more than 10s)
Compiling lib/ecto/adapters/postgres.ex (it's taking more than 10s)
Generated ecto app
==> phoenix_ecto
Compiling 4 files (.ex)
Generated phoenix_ecto app
==> phoenix_chat
Compiling 19 files (.ex)
Generated phoenix_chat app
08:49:48.868 [error] GenServer #PID<0.3296.0> terminating
** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
(db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
** (Mix) The database for PhoenixChat.Repo couldn't be created: an exception was raised:
** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
(db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Build failed !!!.
我认为这是因为构建服务器似乎(localhost:5432)
,我认为它与通常在端口 4000 上的 Phoenix 配合不佳。请参阅此答案,以便我得出该结论。
对此的解决方案是什么?
我更改了dev.ex以具有此配置:
config :phoenix_chat, PhoenixChat.Endpoint,
http: [port: {:system, "PORT"}],
然后我将任务设置为 PORT=4000 mix test
但仍然收到相同的错误。
编辑:似乎我的设置端口不起作用,因为错误仍然存在:
PORT=4000 mix test
09:18:34.884 [error] GenServer #PID<0.183.0> terminating
** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
(db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
** (Mix) The database for PhoenixChat.Repo couldn't be created: an exception was raised:
** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
(db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Build failed !!!.
所以我现在认为解决方案可能是这个。我对添加 ssh 密钥知之甚少。
我的笔记本电脑崩溃了,在/usr/local/var/postgres
中留下了一个postmaster.pid
文件。
删除此内容后,我的帖子又开始很好地工作了。
如果要检查 Postgres 是否正常运行,可以运行 pg_isready
来获取输出。您应该得到:/tmp:5432 - accepting connections
- 您的端口可能因您的配置而异。
玩得愉快!
也试试brew services stop postgres
brew services start postgres
.它解决了我的问题
您可能会看到libssl/libcrypto版本的冲突。
brew services start postgres
日志给了我nada,但手动启动pg_ctl -D /usr/local/var/postgres start
指向:
缺少/.../openssl/lib/libcrypto.1.0.0.dylib 中的定义_RAND_cleanup
试一试:
brew tap-new $USER/old-openssl
brew extract --version=1.0.2t openssl $USER/old-openssl
brew install openssl@1.0.2t
# and then either brew link openssl@1.0.2t or symlink the required files to current openssl
ln -s /usr/local/Cellar/openssl/openssl@1.0.2t/lib/libcrypto.1.0.0.dylib /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
ln -s /usr/local/Cellar/openssl/openssl@1.0.2t/lib/libssl.1.0.0.dylib /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
停止当前正在运行的 Postgres :
pg_ctl stop
使用以下命令重新启动 Postgres:
pg_ctl start