2

I am using Passenger and Rails' :cache => true to cache all my css into one big file. Deploys are done via Capistrano.

Now sometimes(!), the mem-generated all.css file can't be found after the app is restarted (and I get an error in the log)

ActionController::RoutingError (No route matches "/stylesheets/all.css" with {:method=>:get}):
  passenger (2.2.2) lib/phusion_passenger/rack/request_handler.rb:81:in `process_request'
  passenger (2.2.2) lib/phusion_passenger/abstract_request_handler.rb:203:in `main_loop'

Placing another restart.txt file manually or a cap deploy:restart will resolve the issue.

It's not a big thing, but it's always tedious to check and fix. Anybody has an idea what I am doing wrong?

Edit

My deploy:restart looks like this (exactly what I am doing manually).

desc "Restarting mod_rails with restart.txt"
task :restart, :roles => :app, :except => { :no_release => true } do
  run "touch #{current_path}/tmp/restart.txt"
end

Also I am not using any special (external) CSS files in my caching.

<%= stylesheet_link_tag "clear", "application", "contracts", :cache => true %>

2 Answers 2

1

At the end of your deploy you should be running (as part of the deploy:restart task):

touch tmp/restart.txt

This will let Passenger know it needs to reload the Rails stack for the new code, and the new stylesheets will get cached upon the first request.

What does your current deploy:restart task look like?

Sign up to request clarification or add additional context in comments.

2 Comments

I would also recommend updating Passenger to 2.2.5 for good measure. 2.2.2 was released back in April and it's continually under development with a few solid releases since then.
I included the listing - it's as you would recommend the touch. I might use this evening to upgrade the production server to 2.2.5 and see if this helps on the issue.
1

This specific issue is caused when the list of stylesheets with the cache option contains at least one external stylesheet. It happens only the very first time the app is started.

stylesheet_link_tag "foo.css", "/bar.css", "http://example.org/file.css", :cache => true
# crash
stylesheet_link_tag "foo.css", "/bar.css", :cache => true
# OK

1 Comment

Never even knew that one could use external CSS files in caching. However it's not the case in my situation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.