erros in Ubuntu Terminal when deploying my rails app - ruby-on-rails

I have built a ruby on rails application using Ubuntu. My application is on github. Normally I transfer the latest developments from github to my website, www.mywebsite.com, by doing in Terminal:
cap production deploy:migrations
And everything works fine. I see in Terminal the progress of the transfer like:
* executing "rm -rf /var/www/apps/myapp/releases/20130720123042/public/assets &&\\\n mkdir -p /var/www/apps/myapp/releases/20130720123042/public &&\\\n mkdir -p /var/www/apps/myapp/shared/assets &&\\\n ln -s /var/www/apps/myapp/shared/assets /var/www/apps/myapp/releases/20130720123042/public/assets"
servers: ["92.51.243.6"]
[92.51.243.6] executing command
command finished in 626ms
* executing `bundle:install'
* executing "cd /var/www/apps/myapp/releases/20130720123042 && bundle install --gemfile /var/www/apps/myapp/releases/20130720123042/Gemfile --path /var/www/apps/myapp/shared/bundle --deployment --quiet --without development test"
servers: ["92.51.243.6"]
[92.51.243.6] executing command
command finished in 1595ms
* executing "chmod -R g+w /var/www/apps/myapp/releases/20130720123042"
servers: ["92.51.243.6"]
[92.51.243.6] executing command
command finished in 645ms
Now the process doesn't complete as it used to and I get this message:
* executing "cd /var/www/apps/myapp/releases/20130720123042 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["92.51.243.6"]
[92.51.243.6] executing command
** [out :: 92.51.243.6] rake aborted!
** [out :: 92.51.243.6] Received wrong number of arguments. [nil]
** [out :: 92.51.243.6] /var/www/apps/myapp/shared/bundle/ruby/1.8/gems/omniauth-1.1.0/lib/omniauth/strategy.rb:136:in `initialize'
more stuff here like the line above..
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'ree-1.8.7-2012.02' -c 'cd /var/www/apps/myapp/releases/20130720123042 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on 92.51.243.6
mypc#ubuntu:~/myapp$
Any idea how I can fix this problem? Thanks.

Related

Mina Deploy Not Working All the Time

I have been having this issue for 3 months or so now. When I do a mina deploy no errors will happen and it shows starting/stopping of sidekiq etc.. but sometimes the latest code doesn't actually deploy to the production server. Using the same code I have never had this issue on the staging environment either, which is really confusing.
To fix the issue, I have to manually kill the unicorn pid and then do a re-deploy and this works every time.
I'm not very familiar with any of this and it is mainly copied from articles & SO, but do you see anything in the code that could be causing issues? Should I be stopping unicorn and then starting it back up instead of just restarting it? My thought there is that I might miss requests.
desc "Deploys the current version to the server."
task :deploy => :environment do
deploy do
# stop accepting new workers
invoke :'sidekiq:quiet'
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
to :launch do
invoke :'sidekiq:restart'
invoke :'unicorn:restart'
end
end
Is there anyway I can output statements at certain times inside of the deploy or have it create a log?
-- EDIT: (ADDED TRACE) --
This is a passing trace. Is there some type of error that should show up on a failing trace that I can look for? It doesn't fail all the time, but I can run trace each time to try to catch a failing one.
** Invoke deploy (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke rbenv:load (first_time)
** Execute rbenv:load
** Execute deploy
** Invoke sidekiq:quiet (first_time)
** Invoke environment
** Execute sidekiq:quiet
** Invoke git:clone (first_time)
** Execute git:clone
** Invoke deploy:link_shared_paths (first_time)
** Execute deploy:link_shared_paths
** Invoke bundle:install (first_time)
** Execute bundle:install
** Invoke rails:db_migrate (first_time)
** Execute rails:db_migrate
** Invoke rails:assets_precompile (first_time)
** Execute rails:assets_precompile
** Invoke deploy:cleanup (first_time)
** Execute deploy:cleanup
** Invoke sidekiq:restart (first_time)
** Execute sidekiq:restart
** Invoke sidekiq:stop (first_time)
** Invoke environment
** Execute sidekiq:stop
** Invoke sidekiq:start (first_time)
** Invoke environment
** Execute sidekiq:start
** Invoke unicorn:restart (first_time)
** Invoke environment
** Execute unicorn:restart
-----> Loading environment
$ source ~/.bashrc
-----> Loading rbenv
$ export RBENV_ROOT="$HOME/.rbenv"
$ export PATH="$HOME/.rbenv/bin:$PATH"
$ eval "$(rbenv init -)"
-----> Creating a temporary build path
$ touch "deploy.lock"
$ mkdir -p "$build_path"
$ cd "$build_path"
-----> Quiet sidekiq (stop accepting new work)
$ RAILS_ENV="staging" bundle exec sidekiqctl quiet /home/deploy/PATH $ RAILS_ENV="staging" bundle exec sidekiqctl quiet /home/deploy/PATHNAME//shared/pids/sidekiq.pid
-----> Fetching new git commits
$ (cd "/home/deploy/PATHNAME//scm" && git fetch "git#github.com:k $ (cd "/home/deploy/PATHNAME//scm" && git fetch "git#github.com:kenmazaika/PATHNAME.git" "master:master" --force)
-----> Using git branch 'master'
$ git clone "/home/deploy/PATHNAME//scm" . --recursive --branch " $ git clone "/home/deploy/PATHNAME//scm" . --recursive --branch "master"
Cloning into '.'...
done.
-----> Using this git commit
$ git --no-pager log --format='%aN (%h):%n> %s' -n 1
MYNAME (a0ba681):
> Merge pull request #2040 from repo/issue2039
$ rm -rf .git
-----> Symlinking shared paths
$ mkdir -p "./config"
$ mkdir -p "."
$ rm -rf "./config/database.yml"
$ ln -s "/home/deploy/PATHNAME//shared/config/database.yml" "./co $ ln -s "/home/deploy/PATHNAME//shared/config/database.yml" "./config/database.yml"
$ rm -rf "./log"
$ ln -s "/home/deploy/PATHNAME//shared/log" "./log"
$ rm -rf "./config/secrets.yml"
$ ln -s "/home/deploy/PATHNAME//shared/config/secrets.yml" "./con $ ln -s "/home/deploy/PATHNAME//shared/config/secrets.yml" "./config/secrets.yml"
-----> Installing gem dependencies using Bundler
$ mkdir -p "/home/deploy/PATHNAME//shared/bundle"
$ mkdir -p "./vendor"
$ ln -s "/home/deploy/PATHNAME//shared/bundle" "./vendor/bundle"
$ bundle install --without development:test --path "./vendor/bundle" --de $ bundle install --without development:test --path "./vendor/bundle" --deployment
### USING A BUNCH OF GEMS ###
-----> DB migrations unchanged; skipping DB migration
-----> Skipping asset precompilation
$ cp -R "/home/deploy/PATHNAME//current/public/assets" "./public"
-----> Cleaning up old releases (keeping 5)
$ cd "/home/deploy/PATHNAME//releases" || exit 15
$ count=`ls -1d [0-9]* | sort -rn | wc -l`
$ remove=$((count > 5 ? count - 5 : 0))
$ ls -1d [0-9]* | sort -rn | tail -n $remove | xargs rm -rf {}
-----> Build finished
-----> Moving build to releases/301
$ mv "$build_path" "$release_path"
-----> Updating the current symlink
$ ln -nfs "$release_path" "current"
-----> Launching
$ cd "$release_path"
-----> Stop sidekiq
$ RAILS_ENV="staging" bundle exec sidekiqctl stop /home/deploy/PATHl $ RAILS_ENV="staging" bundle exec sidekiqctl stop /home/deploy/PATHNAME//shared/pids/sidekiq.pid 10
Sidekiq shut down gracefully.
-----> Start sidekiq
$ nohup bundle exec sidekiq -e staging -C /home/deploy/PATHNAME//current/config/sidekiq.yml -i 0 -P /home/deploy/PATHNAME//shared/pids/si $ nohup bundle exec sidekiq -e staging -C /home/deploy/PATHNAME//current/config/sidekiq.yml -i 0 -P /home/deploy/PATHNAME//shared/pids/sidekiq.pid >> /home/deploy/PATHNAME//current/log/sidekiq.log 2>&1 &
-----> Starting Unicorn...

Getting a Pending Migrations error on my rails app after deployment

I've been trying to deploy my site to Webfaction from Github via Capistrano 2, and I've definitely made some progress.
Here's my repo: https://github.com/jaronoff/new_site
I'm trying to deploy to josharonoff.com
I finally have my deploy.rb the way I want it, and I checked cap deploy:status works fine, I run cap deploy and it works fine, but I for some reason am getting this error even though I've restarted via the deploy.rb file.
error:
ActiveRecord::PendingMigrationError at /
Migrations are pending; run 'bin/rake db:migrate RAILS_ENV=development' to resolve this issue.
When I run the cap deploy, the output I get says that it's deployed correctly, and even does the db migration to the rails env of production... so I'm not sure what I'm doing wrong.
Here's the output from the console when I run cap deploy:
* 2014-02-13 14:43:39 executing `deploy'
* 2014-02-13 14:43:39 executing `deploy:update'
** transaction: start
* 2014-02-13 14:43:39 executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote git#github.com:jaronoff/new_site.git master"
command finished in 2251ms
* executing "if [ -d /home/jaronoff/webapps/ac_site/shared/cached-copy ]; then cd /home/jaronoff/webapps/ac_site/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 3b7d990f32d1fa2bdb7153d1c00548fec510eb33 && git clean -q -d -x -f; else git clone -q -b master git#github.com:jaronoff/new_site.git /home/jaronoff/webapps/ac_site/shared/cached-copy && cd /home/jaronoff/webapps/ac_site/shared/cached-copy && git checkout -q -b deploy 3b7d990f32d1fa2bdb7153d1c00548fec510eb33; fi"
servers: ["web432.webfaction.com"]
[web432.webfaction.com] executing command
command finished in 1956ms
copying the cached version to /home/jaronoff/webapps/ac_site/releases/20140213194344
* executing "cp -RPp /home/jaronoff/webapps/ac_site/shared/cached-copy /home/jaronoff/webapps/ac_site/releases/20140213194344 && (echo 3b7d990f32d1fa2bdb7153d1c00548fec510eb33 > /home/jaronoff/webapps/ac_site/releases/20140213194344/REVISION)"
servers: ["web432.webfaction.com"]
[web432.webfaction.com] executing command
command finished in 233ms
* 2014-02-13 14:43:44 executing `deploy:finalize_update'
* executing "chmod -R -- g+w /home/jaronoff/webapps/ac_site/releases/20140213194344 && rm -rf -- /home/jaronoff/webapps/ac_site/releases/20140213194344/public/system && mkdir -p -- /home/jaronoff/webapps/ac_site/releases/20140213194344/public/ && ln -s -- /home/jaronoff/webapps/ac_site/shared/system /home/jaronoff/webapps/ac_site/releases/20140213194344/public/system && rm -rf -- /home/jaronoff/webapps/ac_site/releases/20140213194344/log && ln -s -- /home/jaronoff/webapps/ac_site/shared/log /home/jaronoff/webapps/ac_site/releases/20140213194344/log && rm -rf -- /home/jaronoff/webapps/ac_site/releases/20140213194344/tmp/pids && mkdir -p -- /home/jaronoff/webapps/ac_site/releases/20140213194344/tmp/ && ln -s -- /home/jaronoff/webapps/ac_site/shared/pids /home/jaronoff/webapps/ac_site/releases/20140213194344/tmp/pids"
servers: ["web432.webfaction.com"]
[web432.webfaction.com] executing command
command finished in 254ms
* executing "find /home/jaronoff/webapps/ac_site/releases/20140213194344/public/images /home/jaronoff/webapps/ac_site/releases/20140213194344/public/stylesheets /home/jaronoff/webapps/ac_site/releases/20140213194344/public/javascripts -exec touch -t 201402131943.44 -- {} ';'; true"
servers: ["web432.webfaction.com"]
[web432.webfaction.com] executing command
** [out :: web432.webfaction.com] find: `/home/jaronoff/webapps/ac_site/releases/20140213194344/public/images': No such file or directory
** [out :: web432.webfaction.com] find: `/home/jaronoff/webapps/ac_site/releases/20140213194344/public/stylesheets': No such file or directory
** [out :: web432.webfaction.com] find: `/home/jaronoff/webapps/ac_site/releases/20140213194344/public/javascripts': No such file or directory
command finished in 195ms
* 2014-02-13 14:43:45 executing `deploy:create_symlink'
* executing "rm -f /home/jaronoff/webapps/ac_site/current && ln -s /home/jaronoff/webapps/ac_site/releases/20140213194344 /home/jaronoff/webapps/ac_site/current"
servers: ["web432.webfaction.com"]
[web432.webfaction.com] executing command
command finished in 198ms
** transaction: commit
* 2014-02-13 14:43:45 executing `deploy:restart'
triggering before callbacks for `deploy:restart'
* 2014-02-13 14:43:45 executing `deploy:migrate'
* executing "cd /home/jaronoff/webapps/ac_site/releases/20140213194344 && rake RAILS_ENV=production db:migrate"
servers: ["web432.webfaction.com"]
[web432.webfaction.com] executing command
command finished in 1939ms
* executing "/home/jaronoff/webapps/ac_site/bin/restart"
servers: ["web432.webfaction.com"]
[web432.webfaction.com] executing command
command finished in 3217ms
Any help or anything would be greatly appreciated. I've gotten pretty far today just by trial and error.
Thanks in advance!!
~Josh

Rubber gem having issue with graphite server

I am having an issue with using rubber, whenever I try cap rubber:bootstrap and had a staging instance, it always stuck on this error.
* executing "sudo -p 'sudo password: ' bash -l -c 'cd /mnt/localstore-production/releases/20120519213905 && RUBBER_ENV=production RAILS_ENV=production ./script/rubber config --force --file=\"role/graphite_server\"'"
servers: ["production.localstore.com"]
[production.localstore.com] executing command
** [out :: production.localstore.com] Instance not found for host: ip-10-2-118-252
** [out :: production.localstore.com]
command finished in 5849ms
failed: "/bin/bash -l -c 'sudo -p '\\''sudo password: '\\'' bash -l -c '\\''cd /mnt/localstore-production/releases/20120519213905 && RUBBER_ENV=production RAILS_ENV=production ./script/rubber config --force --file=\"role/graphite_server\"'\\'''" on production.localstore.com
Actually the issue was that I changed the static IP of the instance from the AWS Console, so why the host info of the instance changed some how.
So I use this command cap rubber:referesh to refresh every thing and then bootstrap the instance and it solved my problem.

Capistrano / Mercurial / tar "time stamp in the future" Message

I'm experiencing an intermittent problem when deploying my rails app with capistrano. After the .gz is uploaded to the server, the log shows an error coming from tar, which says that the time stamp is in the future (see output below). This message repeats for what seems to be every file in the app.
I compared the server time against the numeric name of the .tar.gz file, and it's indeed a few minutes ahead. But how does this correlate to the actual timestamp on the files? And how can I get my changes to deploy correctly?
** sftp upload /var/folders/lo/loIUAyGAHFWqSREiNHhm-E+++TI/-Tmp-/20110603143429.tar.gz -> /tmp/20110603143429.tar.gz
[123.45.67.890] /tmp/20110603143429.tar.gz
[123.45.67.890] done
* sftp upload complete
* executing "cd /home/blah/releases && tar xzf /tmp/20110603143429.tar.gz && rm /tmp/20110603143429.tar.gz"
servers: ["123.45.67.890"]
[123.45.67.890] executing command
** [out :: 123.45.67.890] tar: 20110603143429/.autotest: time stamp 2011-06-03 14:34:33 is 368.72042712 s in the future
** [out :: 123.45.67.890] tar: 20110603143429/.bundle: time stamp 2011-06-03 14:34:33 is 368.719540808 s in the future
** [out :: 123.45.67.890] tar: 20110603143429/.hgignore: time stamp 2011-06-03 14:34:33 is 368.719465444 s in the future
** [out :: 123.45.67.890] tar: 20110603143429/app: time stamp 2011-06-03 14:34:34 is 369.719382175 s in the future
** [out :: 123.45.67.890] tar: 20110603143429: time stamp 2011-06-03 14:34:49 is 383.369448435 s in the future
command finished in 1616ms
* executing `deploy:finalize_update'
* executing "chmod -R g+w /home/blah/releases/20110603143429"
servers: ["123.45.67.890"]
[123.45.67.890] executing command
command finished in 193ms
* executing "rm -rf /home/blah/releases/20110603143429/log /home/blah/releases/20110603143429/public/system /home/blah/releases/20110603143429/tmp/pids &&\\\n mkdir -p /home/blah/releases/20110603143429/public &&\\\n mkdir -p /home/blah/releases/20110603143429/tmp &&\\\n ln -s /home/blah/shared/log /home/blah/releases/20110603143429/log &&\\\n ln -s /home/blah/shared/system /home/blah/releases/20110603143429/public/system &&\\\n ln -s /home/blah/shared/pids /home/blah/releases/20110603143429/tmp/pids"
servers: ["123.45.67.890"]
[123.45.67.890] executing command
command finished in 257ms
* executing "find /home/blah/releases/20110603143429/public/images /home/blah/releases/20110603143429/public/stylesheets /home/blah/releases/20110603143429/public/javascripts -exec touch -t 201106031435.03 {} ';'; true"
servers: ["123.45.67.890"]
[123.45.67.890] executing command
command finished in 1911ms
triggering after callbacks for `deploy:update_code'
* executing `bundle:install'
* executing "ls -x /home/blah/releases"
servers: ["123.45.67.890"]
[123.45.67.890] executing command
command finished in 140ms
* executing "bundle install --gemfile /home/blah/releases/20110603143429/Gemfile --path /home/blah/shared/bundle --deployment --quiet --without development test"
servers: ["123.45.67.890"]
[123.45.67.890] executing command
** [out :: 123.45.67.890] sh: bundle: not found
command finished in 158ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/blah/releases/20110603143429; true"
servers: ["123.45.67.890"]
[123.45.67.890] executing command
command finished in 261ms
failed: "sh -c 'bundle install --gemfile /home/blah/releases/20110603143429/Gemfile --path /home/blah/shared/bundle --deployment --quiet --without development test'" on 123.45.67.890
It sounds like you have have clock-skew. All all the computers involved in the process -- those commiting, those sending, those receiving/deploying in sync?

ferret_server start problem druing the deploy

When do the cap deploy everything works fine except the ferret-server, while restarting server its try to stop the ferret_server in production mode and try to start the ferret_server but it fails due to permission problem .Here is the output from my deploy file** transaction: commit
executing deploy:restart'
triggering before callbacks fordeploy:restart'
executing `ferret:stop'
executing "cd /home/sj/reelinfo/current; script/ferret_server -e production stop || true"
servers: ["67.23.28.171"]
[67.23.28.171] executing command
** [out :: 67.23.28.171] sh: script/ferret_server: Permission denied
command finished
executing "chown www-data -R /home/sj/reelinfo/current/"
servers: ["67.23.28.171"]
[67.23.28.171] executing command
command finished
executing "touch /home/sj/reelinfo/current/tmp/restart.txt"
servers: ["67.23.28.171"]
[67.23.28.171] executing command
command finished
triggering after callbacks for `deploy:restart'
executing `ferret:start'
executing "cd /home/sj/reelinfo/current; script/ferret_server -e production start"
servers: ["67.23.28.171"]
[67.23.28.171] executing command
** [out :: 67.23.28.171] sh: script/ferret_server: Permission denied
command finished
failed: "sh -c \"cd /home/sj/reelinfo/current; script/ferret_server -e production start\"" on 67.23.28.171
I've had this problem as well, the issue is that script/ferret_server did not have executable permissions.
I added the following deploy task to handle the permissions:
before "deploy:restart", "correct_ferret_server_permissions"
task :correct_ferret_server_permissions do
run "chmod a+x #{current_path}/script/ferret_server
end

Resources