My app - cloudlist (cloudli.st) - uses Heroku, rails 3.2 and a bunch of gems. For the past few days we've started seeing our layout break a few hours after a deploy.
The strange thing is that the content of a file switches randomly on different requests. We use the rails asset pipeline with all defaults, nothing changed. Right after the deploy everything is fine. After some time (usually a couple of hours) the layouts starts to break in some areas. Sometimes just one image has a different content, sometimes even JS or CSS files have different content. We've also seen files that were completely mixed up. All this is very strange and I can't find anything on the web.
To illustrate the problem see the following image which have sprites with the wrong content.
Also see the content of the file frame.png. It should show the frame for a tile but sometimes it shows the awards nominee badge.
Has anyone seen anything similar or do you know how to solve this?
If this continues we need to migrate away from Heroku and use another infrastructure.
According to the recommendation given by heroku (https://devcenter.heroku.com/articles/rack-cache-memcached-rails31) here are the results.
In short: it didn't help.
Long version:
I don't use memcached for caching. Neither I use fragment or action caching. At least I don't use caching at all in my app.
The only thing that gets cached is stuff done by the configuration parameter
config.action_controller.perform_caching = false
in production environment.
I went through the article and checked every parameter. The only one I had different was config.serve_static_assets which was false. I set this to true, redeployed (with caching turned on) and got the same issues after a couple of hours.
I don't know what's wrong but as there is content in my files which doesn't match the expected I have to conclude that this is something within your infrastructure. E.g. I request application-(any-digest).css and I get sprite-(any-digest).png or application-(any-digest).js
Related
I pushed a sample app I was working on to Heroku. Rails 5 - I now notice a lot of issues/differences, a lot I can relate back to an obvious pipeline issue. Majority of the references I see are from R3/R4 but mention putting
config.assets.compile = true
config.assets.digest = true
in and modifying all url to font-url or image-url - I did that for majority of the fonts, but I'm still seeing blank images, and broken links/missing icons.
Another weird thing is I used JSON Builder to builds out a site.json page - The page itself is actually fine; No issues. However, when I try to limit it with a parameter it immediately returns a 500 error. I've found 4-5 other posts on SO about this, each with a minor amount of replies, and usually they say to do what I mentioned above.
I even tried to go into all of my CSS files cores, and change it to
font-url('<%= asset_path("mana.eot?#iefix&v=1.3.0") %>') which also didn't do anything.
I read on Heroku's help site that it has issues due to the MD5 fingerprint and I followed through the steps to connect to the bash to see the file's existance AND the name, but I'm unsure how to really.... do anything about that? Don't they have the same fingerprint when locally compiled/C9/IDE?
In terms of photos missing, you probably have to upload them to AWS or something similar and save the information there. Make an account and follow the instructions, it is pretty straight forward. I had the same problem for my app and that was the solution for me.
In terms of links make sure none of them are localhost:3000 because that will break the links.
I am trying to use a reverse proxy to serve a Wordpress blog running on EC2 at /blog from a rails app running on Heroku. I've used the rack-reverse-proxy gem and followed directions like this:
How can I use a subdirectory instead of a subdomain?
My app is running at http://myapp.com, my main target (wordpress) server is running at http://ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com.
The pages on the target server all serve up fine when accessed directly. However, no matter what page I try to get through the reverse proxy, the HTML gets cut off. I've tried serving via both my own custom builds of Wordpress on Ubuntu (EC2) and on hosted examples like Bluehost. I've tried to access simple, handmade HTML and text test files, as well as the php files automatically generated by wordpress. Every time, the file is cut off.
Text files just get randomly cut off after ~1000 characters (this is variable)
Ditto for hand-coded HTML files
Wordpress files seem to get cutoff during the <head> (often mid-word) and render an empty <body>.
If a page should exist (e.g. http://ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com/test-post, it will load (at least partially) at myapp.com/blog/test-post, so I don't know that rewrites are the issue.
I've tried enough variables on the wordpress/destination server that I'm inclined to think it's something on the Rails side (I have the same issue whether running "myapp" locally or on a Heroku test server). Beyond that, I'm stuck.
Any thoughts as to what I might be doing wrong? There's nothing in the Apache logs to indicate that anything is getting cut off. I'm pounding my head over this to no avail, and would really appreciate any help.
FIXED IT!
Digging into the rack-reverse-proxy gem, I found that I'm not the only person that had an issue with this:
Seeing some issues with Content-Length being corrupted, this ensures it matches body length as delivered.
The fix hasn't been merged into the master branch, but I forked my own copy, applied the fix, and it's working great. Hopefully it'll be merged into the master and nobody else will have to worry about this.
EDIT
One more thing that might be helpful for somebody else, if they are having problems with Visual Editing Mode not working under wordpress: Make sure that you also include this update to have the headers get passed in properly. The gem just hasn't really been updated in a couple of years, so it's up to you to go through and copy in fixes from other people. Applying those two fixes has everything working fine for me with a Heroku app/AWS&Ubuntu Wordpress setup.
Heroku will cut the request after a certain amount of time which would cause the behavior that you're seeing.
You basically have to pull the page from the wordpress blog and reserve it via Rack in the time for one request - think that could be the problem?
I'm on Rails 3.1.1 and I have noticed my app has become exceedingly slow (15 seconds) in development mode. See my firebug 'Net' listing below:
I've done a number of things like:
reducing the number of gems
turning class caching on
turning asset debugging to false
turning asset compression to true
installing the rails-dev-boost gem
Maybe there were some improvements, but nothing helped it to go as fast I'd expect when running off localhost. That is, until I commented out my observers config line in application.rb:
config.active_record.observers = :item_observer, :loan_observer, :friendship_observer, :message_observer, :user_observer
And then the app was fast again (~1 sec) load time. See the firebug listing now:
Other notes:
When in production on Heroku, it's fast (~1 sec), as you'd expect.
I'm using postgresql and Thin; I have not tried using other DBs to see if this problem exists.
When I commented out just the last observer, user_observer, the load time dropped by about half.
The load times printed in development.log do not reflect actual load times. Assets were flagged as 304 Not Modified (0ms) they really took a while to load.
Yes, I'm using the asset pipeline
The Golden Question: Is the simple act of registering observers causing assets to load slowly? And what can be done about it?
Take a look at https://github.com/wavii/rails-dev-tweaks.
Rails is running all of the to_prepare hooks on every Sprockets asset request in development mode. This includes things like auto-(re)loading your code, and various gems perform work in there too. And in your case, observers are being registered (which - I believe - causes Rails to reference a good portion of your app in order to reference the models)
rails-dev-tweaks disables to_prepare & reloading on any asset request (and a few others - read the first part of its README). Speeds up your dev environment by a huge amount for any decently sized project. It's also configurable to do this for any additional requests you like
The way I am fixing this is refactoring the observers into concerns. https://gist.github.com/1014971
I have a Rails 3 based CMS that allows users to create and modify layouts and views. These layouts and views are the same ones built into the framework, only backed by a model for some additional capabilities. The problem I would like to address is that these template files are cached as soon as they are accessed on the public end, so it is not possible to see changes in the layouts or views unless the server is restarted. This does not occur in development mode where caching is disabled, but obviously turning off template caching in production wouldn't be great for performance. Clearing memcache doesn't seem to do the trick. Is it possible to programatically clear out the layouts and views cache in production, perhaps with something like reload! like we have in the console? Or am I stuck having to restart Passenger every time someone wants to tweak one of these layouts or views (perhaps using the approach in this thread: Rails Cache Clearing)?
Please note that I am not referring to clearing the page and action caches, which the public pages rely on and works just fine.
José Valim has a great chapter in "Crafting Rails Applications" that goes over this topic. Here is an approach that uses Mongoid to store view templates. If you build your own view Resolver, then you just need to call #clear_cache on the resolver instance when someone saves a new template in the database.
this configuration may help (at least it worked* for me):
config.action_view.cache_template_loading = false
works in rails 3
There's just a slight difference in rails 2:
config.action_view.cache_template_reloading = false
In production mode, it's normal to require a restart to implement rails code changes, which is what you are doing by editing the layouts and views. It sounds like you're really operating in a development environment if you are editing the application code while it's running. In production mode I don't know of a way to refresh Passenger without touching restart.txt or restarting the web server.
EDIT: You should be able to touch tmp/restart.txt programmatically from within your app. This should tell Passenger to reload on the next request.
I've added a subdirectory app/renderers after Railscast #101. The classes in that directory are not getting reloaded by my development server. It's driving me a little bonkers.
I've read everything I could find on forcing it to reload lib and/or plugins but this seems to be a different case since "everything under app should be reloaded automatically." Plus, I've checked ActiveSupport::Dependencies.load_once_paths, and app/renderers definitely isn't in it.
I'd also like to get the renderers to be automatically required, so that I don't have to go around putting require statements in the rest of my code. Is that sensible? How does it work for, say, models and other constants?
Doh. I should have been loading the files, not requiring them.
I'd still like to have them magically loaded -- not needing a specific load statement for each one -- but for now it's working :)