【问题标题】:Capistrano giving error from old release. ActionView::MissingTemplateCapistrano 从旧版本中给出错误。 ActionView::MissingTemplate
【发布时间】:2014-03-10 13:09:13
【问题描述】:

我已经在AWS 上使用capistrano 部署了我的应用程序,nginxunicorn。当我打开我的主页时,它是空的。这是我的unicorn日志

Started GET "/" for 111.111.111.111 at 2014-03-10 12:50:02 +0000
Processing by StaticController#index as HTML
Completed 500 Internal Server Error in 236ms

ActionView::MissingTemplate (Missing template static/index with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee, :haml]}. Searched in:
  * "/home/deployer/apps/my-app/releases/20140310084512/app/views"
  * "/home/deployer/apps/my-app/shared/bundle/ruby/1.9.1/gems/twitter-bootstrap-rails-2.2.8/app/views"
  * "/home/deployer/apps/my-app/shared/bundle/ruby/1.9.1/gems/glimpse-redis-1.1.0/app/views"
  * "/home/deployer/apps/my-app/shared/bundle/ruby/1.9.1/gems/glimpse-git-1.0.1/app/views"
  * "/home/deployer/apps/my-app/shared/bundle/ruby/1.9.1/gems/glimpse-0.0.5/app/views"
  * "/home/deployer/apps/my-app/shared/bundle/ruby/1.9.1/gems/kaminari-0.15.1/app/views"
  * "/home/deployer/apps/my-app/shared/bundle/ruby/1.9.1/gems/devise-3.2.3/app/views"
  * "/home/deployer/apps/my-app/releases/20140310124541"
  * "/"
):
  app/controllers/static_controller.rb:8:in `index'

我的最新版本是20140310124541,但缺少模板错误来自以前的版本20140310084512。可能是什么问题。 current 文件夹符号链接已正确创建。

【问题讨论】:

    标签: ruby-on-rails capistrano unicorn


    【解决方案1】:

    您需要确保重新启动 nginx/unicorn。一旦程序在符号链接中查找文件夹/文件,它将指向目标。因此,当 capistrano 指向最新版本时,nginx 仍在查看现在很可能已删除的旧目标。

    确保您已重新启动任务设置,如下所示:https://github.com/sosedoff/capistrano-unicorn

    【讨论】:

    • 嗨,akshah,感谢您的回答。我已经重启了 nginx 和 unicorn,但是没有运气。
    • 问题肯定是 nginx/unicorn 看错了文件夹。您的独角兽配置没有查看当前文件夹,或者您在更新符号链接后没有重新启动。也许,重新启动发生在设置符号链接之前。您的重启任务及其之前/之后的命令是什么样的?
    • 是的,问题出在重启上。由于某种奇怪的原因,重新启动命令不起作用。但是当我停止并开始时,它起作用了。谢谢!
    • 对我来说同样的事情,常规部署不起作用,但手动停止然后启动服务器修复它。
    【解决方案2】:

    --trace 标志给了我更多信息。在我的情况下,宝石丢失了,我没有发现错误。 passenger 是宝石。

    【讨论】:

      【解决方案3】:

      akshah123 的解决方案就是答案,如果这可能对其他人有所帮助,我想分享我的观察结果。

      在 deploy/your_environment.rb(例如:deploy/staging.rb)或deploy.rb,您可以添加:

      after 'deploy:publishing', 'deploy:restart'
      namespace :deploy do
        desc 'for resetting symlinks that are getting stuck in the normal deploy process'
        task :restart do
          invoke 'unicorn:reload'
        end
      end
      

      根据 Capistrano 的设置方式,您可能会看到以下内容:

      Skipping task `unicorn:start'.
      Capistrano tasks may only be invoked once. Since task `unicorn:start' was previously invoked, invoke("unicorn:start") at /Users/newman/.rvm/gems/ruby-2.6.3/gems/capistrano3-unicorn-0.2.1/lib/capistrano3/tasks/unicorn.rake:49 will be skipped.
      If you really meant to run this task again, use invoke!("unicorn:start")
      THIS BEHAVIOR MAY CHANGE IN A FUTURE VERSION OF CAPISTRANO. Please join the conversation here if this affects you.
      

      这在大多数情况下应该没问题,因为正在处理冗余并且重新映射符号链接的预期结果发生了。在这种情况下,消息中建议的修复可能无法/不需要实现,因为我们从调用unicorn:reload 隐式调用unicorn:start,换句话说:invoke! unicorn:reload 不处理/阻止此消息来自渲染。

      【讨论】:

        猜你喜欢
        • 2013-04-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多