ferret_server start problem druing the deploy - ruby-on-rails

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

Related

rubber fails in 'deploy:update_code'

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

sudo password fail trying to setup monit for rails application

I'm following along with Ryan Bates' Railscast on Monit http://railscasts.com/episodes/375-monit?view=asciicast, the monitoring system for Rails applications. In it, he creates a capistrano recipe for monit (see below) which runs with the command cap monit:setup. When I run it, it fails with this message
command finished in 200ms
failed: "sh -c 'sudo -p '\\''sudo password: '\\'' service monit reload'" on 192.XXX.XXX.XXX
It's obviously a password related error, but I can't figure out why it's happening because the earlier commands that the script runs start stop restart syntax reload seem to run successfully until it gets to reload.
Noting that the second last line in the script uses root, I thought it might also be a root issue, since I'm logged into my server with a different user name (but with sudo permissions). Therefore, I changed root in the second last line to my user name and ran cap monit:setup again but I got the same error.
* 2013-07-10 05:52:01 executing `monit:syntax'
* executing "sudo -p 'sudo password: ' service monit syntax"
servers: ["192.XXX.XXX.XXX"]
[192.XXX.XXX.XXX] executing command
** [out :: 192.XXX.XXX.XXX] Control file syntax OK
command finished in 248ms
* 2013-07-10 05:52:02 executing `monit:reload'
* executing "sudo -p 'sudo password: ' service monit reload"
servers: ["192.XXX.XXX.XXX"]
[192.XXX.XXX.XXX] executing command
** [out :: 192.XXX.XXX.XXX] Usage: /etc/init.d/monit {start|stop|restart|force-reload|syntax}
command finished in 200ms
failed: "sh -c 'sudo -p '\\''sudo password: '\\'' service monit reload'" on 192.XXX.XXX.XXX
the Monit.rb recipe
namespace :monit do
desc "Install Monit"
task :install do
run "#{sudo} apt-get -y install monit"
end
after "deploy:install", "monit:install"
desc "Setup all Monit configuration"
task :setup do
monit_config "nginx"
syntax
reload
end
after "deploy:setup", "monit:setup"
%w[start stop restart syntax reload].each do |command|
desc "Run Monit #{command} script"
task command do
run "#{sudo} service monit #{command}"
end
end
end
def monit_config(name, destination = nil)
destination ||= "/etc/monit/conf.d/#{name}.conf"
template "monit/#{name}.erb", "/tmp/monit_#{name}"
run "#{sudo} mv /tmp/monit_#{name} #{destination}"
run "#{sudo} chown root #{destination}"
run "#{sudo} chmod 600 #{destination}"
end

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?

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.

I am trying to deploy my first rails app using Capistrano and am getting an error

My deployment of a rails app with capistrano is failing and I hoping someone can provide me with pointers to troubleshoot.
The following is the command output
andrew#melb-web:~/projects/rails/guestbook2$ cap deploy:setup
* executing `deploy:setup'
* executing "mkdir -p /var/www/dev/guestbook2 /var/www/dev/guestbook2/releases /var/www/dev/guestbook2/shared /var/www/dev/guestbook2/shared/system /var/www/dev/guestbook2/shared/log /var/www/dev/guestbook2/shared/pids && chmod g+w /var/www/dev/guestbook2 /var/www/dev/guestbook2/releases /var/www/dev/guestbook2/shared /var/www/dev/guestbook2/shared/system /var/www/dev/guestbook2/shared/log /var/www/dev/guestbook2/shared/pids"
servers: ["dev.andrewbucknell.com"]
Enter passphrase for /home/andrew/.ssh/id_dsa:
Enter passphrase for /home/andrew/.ssh/id_dsa:
[dev.andrewbucknell.com] executing command
command finished
andrew#melb-web:~/projects/rails/guestbook2$ cap deploy:check
* executing `deploy:check'
* executing "test -d /var/www/dev/guestbook2/releases"
servers: ["dev.andrewbucknell.com"]
Enter passphrase for /home/andrew/.ssh/id_dsa:
[dev.andrewbucknell.com] executing command
command finished
* executing "test -w /var/www/dev/guestbook2"
servers: ["dev.andrewbucknell.com"]
[dev.andrewbucknell.com] executing command
command finished
* executing "test -w /var/www/dev/guestbook2/releases"
servers: ["dev.andrewbucknell.com"]
[dev.andrewbucknell.com] executing command
command finished
* executing "which git"
servers: ["dev.andrewbucknell.com"]
[dev.andrewbucknell.com] executing command
command finished
* executing "test -w /var/www/dev/guestbook2/shared"
servers: ["dev.andrewbucknell.com"]
[dev.andrewbucknell.com] executing command
command finished
You appear to have all necessary dependencies installed
andrew#melb-web:~/projects/rails/guestbook2$ cap deploy:migrations
* executing `deploy:migrations'
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote andrew#dev.andrewbucknell.com:/home/andrew/git/guestbook2.git master"
Enter passphrase for key '/home/andrew/.ssh/id_dsa':
* executing "if [ -d /var/www/dev/guestbook2/shared/cached-copy ]; then cd /var/www/dev/guestbook2/shared/cached-copy && git fetch origin && git reset --hard 369c5e04aaf83ad77efbfba0141001ac90915029 && git clean -d -x -f; else git clone andrew#dev.andrewbucknell.com:/home/andrew/git/guestbook2.git /var/www/dev/guestbook2/shared/cached-copy && cd /var/www/dev/guestbook2/shared/cached-copy && git checkout -b deploy 369c5e04aaf83ad77efbfba0141001ac90915029; fi"
servers: ["dev.andrewbucknell.com"]
Enter passphrase for /home/andrew/.ssh/id_dsa:
[dev.andrewbucknell.com] executing command
** [dev.andrewbucknell.com :: err] Permission denied, please try again.
** Permission denied, please try again.
** Permission denied (publickey,password).
** [dev.andrewbucknell.com :: err] fatal: The remote end hung up unexpectedly
** [dev.andrewbucknell.com :: out] Initialized empty Git repository in /var/www/dev/guestbook2/shared/cached-copy/.git/
command finished
failed: "sh -c 'if [ -d /var/www/dev/guestbook2/shared/cached-copy ]; then cd /var/www/dev/guestbook2/shared/cached-copy && git fetch origin && git reset --hard 369c5e04aaf83ad77efbfba0141001ac90915029 && git clean -d -x -f; else git clone andrew#dev.andrewbucknell.com:/home/andrew/git/guestbook2.git /var/www/dev/guestbook2/shared/cached-copy && cd /var/www/dev/guestbook2/shared/cached-copy && git checkout -b deploy 369c5e04aaf83ad77efbfba0141001ac90915029; fi'" on dev.andrewbucknell.com
andrew#melb-web:~/projects/rails/guestbook2$
The following fragment is from cap -d deploy:migrations
Preparing to execute command: "find /var/www/dev/guestbook2/releases/20100305124415/public/images /var/www/dev/guestbook2/releases/20100305124415/public/stylesheets /var/www/dev/guestbook2/releases/20100305124415/public/javascripts -exec touch -t 201003051244.22 {} ';'; true"
Execute ([Yes], No, Abort) ? |y| yes
* executing `deploy:migrate'
* executing "ls -x /var/www/dev/guestbook2/releases"
Preparing to execute command: "ls -x /var/www/dev/guestbook2/releases"
Execute ([Yes], No, Abort) ? |y| yes
/usr/lib/ruby/gems/1.8/gems/capistrano-2.5.17/lib/capistrano/recipes/deploy.rb:55:in `join': can't convert nil into String (TypeError)
from /usr/lib/ruby/gems/1.8/gems/capistrano-2.5.17/lib/capistrano/recipes/deploy.rb:55:in `load'
I added default_run_options[:pty] = true to my deploy.rb and all worked fine. I am running on debian - I guess it needs its own pty or something to get the right permissions. Thanks for your tips guys.
Looks to me like a permission problem on the server side.
Enter passphrase for /home/andrew/.ssh/id_dsa:
[dev.andrewbucknell.com] executing command
** [dev.andrewbucknell.com :: err] Permission denied, please try again.
** Permission denied, please try again.
** Permission denied (publickey,password).
** [dev.andrewbucknell.com :: err] fatal: The remote end hung up unexpectedly
Looks like git (on the server) is having difficulty authenticating with the git server.
Very helpful for me was to run cap deploy:check before doing anything else. Once that ran error free it was much easier to sort everything else out.

Resources