生产“autoload_paths"中缺少“app"下的自定义目录 [英] Custom directory that is under `app` is missing in production `autoload_paths`
问题描述
我已经为我的应用程序设置了 sidekiq
.我将我的工作人员放在一个新创建的子目录 app/workers/
中.据推测,rails 会自动加载 app/
下的任何子目录.如果我评估
I've setup sidekiq
for my application. I am placing my workers in a newly created subdirectory app/workers/
. Presumably, rails is expected to autoload any subdirectories under app/
. If I evaluate
puts ActiveSupport::Dependencies.autoload_paths
在 Rails 控制台中,在开发中,它确实包括
in a rails console, in development, it does include
".../app/workers"
然而,在生产中,新目录丢失了.我放在 app/
下的其他自定义文件夹,即 services/
和 validators/
,确实出现在用于生产和开发的 autoload_paths 中.
In production however, the new directory is missing. Other custom folders I've placed under app/
, namely services/
and validators/
, do show up in the autoload_paths for both production and development.
我已经看到其他问题的答案,建议重新启动 spring,但是,这对我来说正在生产中发生.
I've seen answers to other questions that suggest restarting spring, however, this is happening in production for me.
services/
和 validators/
在我第一次将我的应用部署到生产环境(使用 Capistrano)时就存在了,而 workers/
来自于后续提交.
services/
and validators/
existed the first time I deployed my app to production (using Capistrano), while workers/
is from a subsequent commit.
推荐答案
我的独角兽部署脚本在 linked_dirs
中包含了 bin/
.Rails 控制台从 bin
启动,因此它需要代表当前版本.我从 shared_dirs
My unicorn deploy script included bin/
in the linked_dirs
. Rails console is booted from bin
so it needs to represent the current release. I removed bin/
from shared_dirs
这篇关于生产“autoload_paths"中缺少“app"下的自定义目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!