Question

I have deployed my app using capistrano on AWS, with nginx and unicorn. When I open my home page, its empty. This is my unicorn log

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'

My latest release is 20140310124541, but the missing template error is coming from a previous release 20140310084512. What could be the issue. The current folder symlink is created properly.

Was it helpful?

Solution

You will need to make sure that you restart nginx/unicorn. Once a program looks up a folder/file in symlink, it will point to the target. So, when capistrano points current to the latest release, nginx still is looking at old target which is now most likely deleted.

Make sure you have restart taks setup as shown here: https://github.com/sosedoff/capistrano-unicorn

OTHER TIPS

--trace flag gave me more info. In my case a gem was missing and I did not spot the error. passenger was the gem.

akshah123's solution is the answer, I wanted to share my observations if that may help others.

in the deploy/your_environment.rb (ex: deploy/staging.rb) or deploy.rb you can add:

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

Depending on how your Capistrano is setup you may see the following:

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.

This should be okay in most cases, as the redundancy is being handled and the desired result of remapping the symlinks occurs. The suggested fix from the message likely can't /doesn't need to be implemented in this case, as we are implicitly calling unicorn:start from calling unicorn:reload, in other words: invoke! unicorn:reload does not handle / prevent this message from rendering.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top