运行 bin/delayed_job启动时,postgres无连接

When running bin/delayed_job start, postgres has no connection

当我 运行 bin/delayed_job start 时,出现以下错误:

Job ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper (id=30) FAILED (0 prior attempts) with ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.

PG::UnableToSend: no connection to the server

通过将以下内容添加到 config/initializers/delayed_job.rb

中解决
ActiveRecord::Base.connection.reconnect!