Why would rake assets:precompile take forever? - ruby

Our RoR app uses quite a few assets that need to be precompiled. It usually took several minutes for assets:precompile to run.
However recently something very strange happened: simple rake assets:precompile never ends (waited few hours).
I've found a workaround:
rake assets:precompile --trace
However it would be great to fix it anyways. Any ideas about a reason?

Does it take forever on your local machine or on the production server?
I had a similar thing when I deployed my app to a AWS micro instance. It took to much CPU and then AWS limits the cpu. See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts_micro_instances.html
Now I precompile my assets locally and the problem is gone.

I had this same issue and came across this awesome gem (by Steve Agalloco) via a gist somewhere. Anyway, works a charm!
https://github.com/spagalloco/capistrano-local-precompile

Related

The application turn off after 1~2 minutes

I was trying to use Heroku to get my bot online 24/7, but there was a problem that my procfile is not recognized (at least I think that's it). I wrote in the procfile:
worker: npm start
however, I didn't see anything like it on Heroku's Dyno tab. If anyone can help me, my entire code is up here: https://github.com/Kasashii/FramedataGarotada
Rename the procfile to Procfile, as specified by Heroku documentation

Heroku timeout with custom Buildpack

I have a custom Heroku Buildpack that compiles CMake and OpenCV. The problem is, OpenCV takes FOREVER to compile. I've tried precompiling OpenCV and pulling it in during my build; however, I have not yet been successful in doing so.
I recently came across the COMPILE_TIMEOUT=n env variable that can be set to override the 15 minute timeout, but it's not working. Does anyone know if this env is still supported? Or if there is another approach besides precompiling?
I would ideally like to have the flexibility of compiling on the fly if I update to the latest version of OpenCV (compilations are cached on Heroku so I'm not waiting around for a full build on every deploy).
I think your best shot would be to build your binaries beforehand. However, Heroku still doesn't have great support for this.
See these links for some suggestions:
https://discussion.heroku.com/t/compiling-a-custom-binary-for-buildpack/224
https://discussion.heroku.com/t/opencv-and-statically-compiled-python/105
Pre-compiling binaries is the way to go; however, it requires time and effort that I'd rather avoid. I reached out to Heroku and they were willing to increase our build time to 30 minutes. Unfortunately, 30 minutes was still not enough to compile OpenCV. The Heroku team was kind enough to Anvil which happens to be the same build service that runs on Heroku. Looks promising!
https://github.com/ddollar/heroku-anvil

fixing css after rake:assets precompile - how to not run capistrano

I recently changed an image on the landing page of my herokuapp built in rails. I realized that everything worked fine except that the landing page threw a 500 error. Upon some research I realized i should run RAILS_ENV=production bundle exec rake assets:precompile
After doing so, the images and some of the styling came back but some of it is still screwy and I cannot understand why.
I've read through just about every stackoverflow thread, the rails guide on the asset pipeline, and others but I can't get it to work. I've amended the files that need amending
as far as I know but nothing is working to make the styling revert to how it should be.
However, on the rails guide it notes that there are two caveats to locally precompile:
You must not run the Capistrano deployment task that precompiles
assets. You must change the following two application configuration
settings. In config/environments/development.rb, place the following
line:
config.assets.prefix = "/dev-assets"
I did the change within development.rb but I am not sure on how I can not run Capistrano. I dont think I'm doing that so maybe it's throwing some things off - idk, but each time I try to recompile now, the rake aborts. Any help is very much appreciated.

Rails 3.1 not detecting Coffeescript and Javascript changes?

Sometimes I update my Coffee code in Rails 3.1 and it doesn't detect any of the changes, ie. I refresh my browser/cache and it still invokes the old script. Anyone know what causes this?
EDIT: I even litter my entire scripts with "debugger" and none of them ever gets called. Any idea why it simply won't refresh the Coffeescripts?
EDIT2: I realize that it doesn't even detect javascript changes sometimes. Am I missing something? Note I am not bouncing my server when I change JS files... It used to work...
For the development environment you could try to rake assets:clean. Rails sometimes reads the precompiled assets in development environment, so this will clean them and the fresh ones will be loaded.
For the production environment try to rake assets:precompile, so that the changes are compiled and stored in the assets files.
For the curious, it suddenly started functioning correctly again by itself. I have reason to believe it was actually the Daylight Savings Time that caused this bug. Not sure if this could be the case but it suspiciously started working again naturally after a fixed amount of time (about 1 hour).
Try rake assets:precompile, if you haven't already.

How do I run my modular Sinatra app?

I'm building a new version of Lovers with Sinatra. You can view the Lovers source code on GitHub.
I'm able to successfully run my app in cucumber mode by running cucumber via the CLI from the root directory of the repository. But...
1) how do I run the app in development mode?
It's a little tricky because it's a modular app, and I've moved the app.rb file to lib/lovers/application.rb.
2) How do I run it with shotgun so that it automatically restarts the app on every HTTP request?
3) When you run ruby app.rb for a Sinatra app, what does that actually do?
If you answer part 3) well, I think I'll be able to figure out the answer to 1 & 2.
Thanks!
1) Just run bundle exec shotgun from the project root. Shotgun, as opposed to other rack servers like thin, is specifically designed... actually... only designed for "development" mode... in that it reloads your code if it changes.
2) Why on every request? Shotgun automatically reloads as needed.
3) ruby app.rb runs a small app server (as seen here: http://www.sinatrarb.com/) but is probably not what you want. Shotgun should do the trick.
The important thing to see here is config.ru in loversapp's root directory. That's what shotgun and other rack servers are looking for. It loads your lib/lovers/application.rb, sets the correct RACK_ENV, and calls run Lovers::Application.

Resources