rubber fails in 'deploy:update_code' - ruby-on-rails

Trying to deploy a simple rails to staging on ec2 with rubber. Process fails with following error. Have been trying for days to find a solution but can't figure it out.
Anyone know why it fails?
* 2014-03-05 15:20:13 executing `deploy:setup'
* executing "sudo -p 'sudo password: ' mkdir -p /mnt/bott.ly-production /mnt/bott.ly-production/releases /mnt/bott.ly-production/shared /mnt/bott.ly-production/shared/system /mnt/bott.ly-production/shared/log /mnt/bott.ly-production/shared/pids"
servers: ["staging.bott.ly"]
[staging.bott.ly] executing command
command finished in 1134ms
* executing "sudo -p 'sudo password: ' chmod g+w /mnt/bott.ly-production /mnt/bott.ly-production/releases /mnt/bott.ly-production/shared /mnt/bott.ly-production/shared/system /mnt/bott.ly-production/shared/log /mnt/bott.ly-production/shared/pids"
servers: ["staging.bott.ly"]
[staging.bott.ly] executing command
command finished in 1439ms
triggering after callbacks for `rubber:bootstrap'
* 2014-03-05 15:20:17 executing `rubber:collectd:bootstrap'
* executing "echo $(grep Rubber /etc/collectd/collectd.conf 2> /dev/null)"
servers: ["staging.bott.ly"]
[staging.bott.ly] executing command
command finished in 1208ms
* 2014-03-05 15:20:20 executing `deploy:setup'
* executing "sudo -p 'sudo password: ' mkdir -p /mnt/bott.ly-production /mnt/bott.ly-production/releases /mnt/bott.ly-production/shared /mnt/bott.ly-production/shared/system /mnt/bott.ly-production/shared/log /mnt/bott.ly-production/shared/pids"
servers: ["staging.bott.ly"]
[staging.bott.ly] executing command
command finished in 1187ms
* executing "sudo -p 'sudo password: ' chmod g+w /mnt/bott.ly-production /mnt/bott.ly-production/releases /mnt/bott.ly-production/shared /mnt/bott.ly-production/shared/system /mnt/bott.ly-production/shared/log /mnt/bott.ly-production/shared/pids"
servers: ["staging.bott.ly"]
[staging.bott.ly] executing command
command finished in 269ms
** updating code for bootstrap
* 2014-03-05 15:20:24 executing `deploy:update_code'
* getting (via checkout) revision to C:/Users/solanmi/AppData/Local/Temp/20140305142024
executing locally: xcopy . "C:/Users/solanmi/AppData/Local/Temp/20140305142024" /S/I/Y/Q/E
378 File(s) copied
command finished in 4328ms
* processing exclusions...
* Compressing C:/Users/solanmi/AppData/Local/Temp/20140305142024 to C:/Users/solanmi/AppData/Local/Temp/20140305142024.tar.gz
executing locally: tar czf 20140305142024.tar.gz 20140305142024
command finished in 51ms
shell command failed with return code pid 8760 exit 53

Looks like you are deploying from Windows and you may be missing the tar command locally or it's not in your $PATH
If you want to use Cygwin I recommend you install it using the it's Setup64 or Setup-x86 program. I believe the tar package is one of the default packages that get installed. If not you can find it here: http://gnuwin32.sourceforge.net/packages/gtar.htm

Related

Rails Rubber deployment timeout

I am trying to deploy an Amazon EC2 instance using rubber. On running
cap rubber:create_staging I get the following timeout:
* 2014-04-06 20:14:09 executing `rubber:postgresql:setup_apt_sources'
servers: ["production.foo.com"]
** sftp upload #<StringIO:0x0000000420a748> -> /tmp/configure_postgresql_repository
[production.foo.com] /tmp/configure_postgresql_repository
[production.foo.com] done
* sftp upload complete
* executing "sudo -p 'sudo password: ' bash -l /tmp/configure_postgresql_repository"
servers: ["production.foo.com"]
[production.foo.com] executing command
command finished in 1161ms
* executing "sudo -p 'sudo password: ' bash -l -c 'apt-get -q update'"
servers: ["production.foo.com"]
connection failed for: production.foo.com (Timeout::Error: execution expired)
I tried increasing the timeout to 60 seconds, but it didn't work.
Any suggestions?
Looks like the user you are using to connect with to the instance using Rubber/Capistrano doesn't have passwordless sudo access. Try creating the file /etc/sudoers.d/90-user-you-use-for-rubber with the following content:
user-you-user-for-rubber ALL=(ALL) NOPASSWD:ALL

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

Capistrano current_path set to /u/app for some commands

I've set the deploy_to variable to the necessary path, but Capistrano runs a single task in the u/app/ directory.
Here is the task that is run
executing "cat /u/apps/application/current/REVISION"
That is how variables are set
set :application, "application"
set :deploy_to, "normal_path/#{application}"
Part of the log where it happens is here:
* executing "cat /normal_path/applicaiton/TOUCH_ASSETS | while read asset; do touch -cm -- \"$asset\"; done && rm -f -- /normal/TOUCH_ASSETS"
servers: ["1.1.1.1"]
[1.1.1.1] executing command
command finished in 992ms
* executing "cat /u/apps/application/current/REVISION"
servers: ["1.1.1.1"]
[1.1.1.1] executing command
command finished in 427ms
*** [deploy:update_code] rolling back
* executing "rm -rf /normal_path/applicaiton/releases/20130610233146; true"
servers: ["1.1.1.1", "1.1.1.2"]
[1.1.1.1] executing command
[1.1.1.1] executing command
command finished in 486ms
failed: "sh -c 'cat /u/apps/application/current/REVISION'" on 1.1.1.1
Why does Capistrano use the wrong path?

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