I use Jenkins to test and deploy a Rails 3 application. It fetches the source from a SVN repo, then runs:
bundle install --deployment
bundle exec rake assets:precompile
rake spec
The process is very slow, it takes more than an hour (!), when locally bundle install --deployment takes 3 minutes. I run ps aux on the server during the bundling process and it doesn't seem to be overloaded. What could be the cause of such strange behaviour? How could I fix it?
This may have to do with running Jenkins in the background (and/or as a service). Try running it in the foreground with java -jar jenkins.war an see if it helps.
Related
Env:
Ruby 2.6.3 / Rails 6.0 / Capistrano 3.14.1
Problem:
cap production deploy is very slow, almost 10 minutes. The log shows $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile takes about 8 minutes. I use the same comand and run it locally, it's very quick. So what is the problem and how to reslove it.
The problem is the server performance limit & the solution is https://github.com/stve/capistrano-local-precompile if anyone is interested. It works well for me, which reduce the time to ~20 seconds.
I want to use custom logo-white, logo-black, and favicon in my company installation of GitLab.
I've Googled my butt off and tried eveything I can find to clear these damn images and nothing seems to work.
Here's the only process that seems to run successfully, yet it does not remove the images:
bundle exec rake cache:clear RAILS_ENV=production
service gitlab stop
redis-cli FLUSHALL
bundle exec rake assets:precompile RAILS_ENV=production
service gitlab start
Then I clear my browser cache and go to the domain and there are the same damn images again!
I even deleted all the logo and favicon files I could find completely from the application, and yet somehow they are still there.
HELP!
There's a rake task assets:clean since version 6.0. So run bundle exec rake assets:clean RAILS_ENV=production from the command line and it will remove the assets.
After you nuke them, you'll probably want to run bundle exec rake assets:precompile RAILS_ENV=production to rebuild them.
I was able to combine some of the info here, and successfully replaced the logo using the following steps (note that some commands are slightly different using the latest version of gitlab, 7.11.4, on CentOS 7, so I am adding this as an answer in the hopes that it will be helpful to users with the new version):
Replace the appropriate images in /opt/gitlab/embedded/service/gitlab-rails/app/assets/images
Stop gitlab using sudo gitlab-ctl stop
Refresh the rails cache sudo gitlab-rake assets:clean RAILS_ENV=production followed by sudo gitlab-rake assets:precompile RAILS_ENV=production
Start gitlab using sudo gitlab-ctl start
For some reason I was getting permission errors in the precompile step. This was solved by changing the write permissions to /opt/gitlab/embedded/service/gitlab-rails/public/assets/ to be globally writable (a+w). It seems that gitlab-rake runs as the git user, even though I used sudo. So, after the steps above, I also changed the owner to root (sudo chown -R root:root /opt/gitlab/embedded/service/gitlab-rails/public/assets), and the permissions back using a-w.
I assume that upgrading gitlab will revert the logo back to the original one, but I haven't tried that yet.
I found the answer for anyone looking.
You also have to replace the images in
app/assets/images/
I'm following the instructions of Ryan Bates' Deploy to a VPS Railscast to deploy my app to an ubuntu cloud server on Digital Ocean. After I run cap deploy:cold, a few different commands are executed successfully, but then when it gets to 'executing bundle:install' it stays in 'executing command' mode for a very long time without throwing any kind of error or completing, like this
command finished in 171ms
* 2013-06-27 12:57:07 executing `bundle:install'
* executing "cd /home/michaelj/apps/qbruby2/releases/20130627195707 && bundle install --gemfile /home/michaelj/apps/qbruby2/releases/20130627195707/Gemfile --path /home/michaelj/apps/qbruby2/shared/bundle --deployment --quiet --without development test"
servers: ["192.xxx.xxx.xxx"]
[192.241.129.33] executing command
I looked at some other people's deployments (on Stackoverflow) and saw that this command usually completes in a matter of milliseconds. My whole gemfile has less than 20 gems (i.e. the standard gems plus a few extras), yet deployment has been paused here for more than 20 minutes.
Can you suggest what I might do?
The first step in troubleshooting these issues, is ensuring you can run the commands remotely.
Thankfully, capistrano outputs the commands it's trying to execute. Then you can do copy/paste over to the server.
In my experience, i've seen the ssh server terminating ssh sessions for long running processes. (that is migrations or bundle install for example) For those cases, there are a few options (modifying sshd_config on the server has worked for me)
add these lines to /etc/ssh/sshd_config
ClientAliveInterval 30
ClientAliveCountMax 5
I would like my cron job, which calls a rake task, to use the gems installed in either [rails_app]/vendor/bundle or [rails_app]/vendor/cache. Currently, my system gems are out-of-date, but I cannot update them for various reasons beyond my control.
I tried using bundle exec, but this does not seem to work. The error I get is
usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/spec_set.rb:88:in 'materialize': Could not find rake-0.9.2.2 in any of the sources (Bundler::GemNotFound)
I believe this is because my system's rake is out-of-date. I tried using bundle exec rake _0.9.2.2_ [my_task] in the cron job, but the same error appeared
I tried the whenever gem; this produced the exact error.
So I guess I have two questions:
How do I make cron use the correct rake version? And
How do I point it to gems already in vendor/bundle or vendor/cache?
Note that the site works when deployed in Phusion Passenger.
While hunting a solution for the same problem I found this Thread with several tips.
the quick & easy way for me was to just run the cron command as login shell - like this:
* * * * * /bin/bash -l -c 'bundle exec rake _0.9.2.2_ [my_task]' 2>&1
the ending 2>&1 is just to be sure to receive errors in cron log. also see man bash for further info!
I am unable to run rake tasks with cron. The error it throws up is:-
/Library/Ruby/Gems/1.8/gems/bundler-1.2.0/lib/bundler/runtime.rb:199: warning: Insecure world writable dir /Library/Ruby/Gems/1.8 in PATH, mode 040777
/Library/Ruby/Gems/1.8/gems/bundler-1.2.0/lib/bundler/spec_set.rb:90:in `materialize': Could not find unf_ext-0.0.5 in any of the sources (Bundler::GemNotFound)
However, when I run the same rake task directly from the terminal, it works fine. In case of the cron job, as well as while running the rake task directly from the terminal, i cd into the (exact) same directory. Starting the rails server works as well.
What is the problem and how should I resolve this?
It could be an issue with your daemon user and your user when you're running it directly. Or it could be a problem with Ruby and/or your cron file commands.
Firstly, use this gem for making cron jobs with rake tasks:
https://github.com/javan/whenever
Then install RVM since you're using the standard ruby library provided by OSX and that can lead to some problems when you're developing various projects. This should fix the permissions error that you have displayed.