here is my deployment.rb file.
# config valid only for current version of Capistrano
lock '3.4.0'
set :stage, 'production'
set :application, "gobgob-ror"
set :repo_url, 'git#github.com:narhamah/gobgob-ror.git'
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, '/home/ubuntu/gobgob-ror'
# Default value for :scm is :git
set :scm, :git
set :branch, "master"
#set :user, "ubuntu"
set :use_sudo, false
set :rails_env, "production"
set :deploy_via, :remote_cache
set :ssh_options, { user: 'ubuntu', :forward_agent => true, :port => 22, keys: ["#{ENV['HOME']}/.ssh/id_rsa"]}
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
# set :log_level, :debug
# Default value for :pty is false
set :pty, true
server "xx.xx.xxx.xxx", roles: [:app, :web, :db], :primary => true
set :normalize_asset_timestamps, %{public/images public/javascripts public/stylesheets}
# Default value for :linked_files is []
set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
# Default value for linked_dirs is []
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
set :keep_releases, 5
namespace :deploy do
desc "Start the application"
task :start do
on roles(:app) do
execute "cd #{current_path} && RAILS_ENV=#{fetch(:stage)} bundle exec puma -b 'unix://#{shared_path}/sockets/puma.sock' -S #{shared_path}/sockets/puma.state --control 'unix://#{shared_path}/sockets/pumactl.sock' >> #{shared_path}/log/puma-#{fetch(:stage)}.log 2>&1 &", :pty => false
end
end
desc "Stop the application"
task :stop do
on roles => :app do
execute "cd #{current_path} && RAILS_ENV=#{fetch(:stage)} bundle exec pumactl -S #{shared_path}/pids/puma.state stop"
end
end
desc "Restart the application"
task :restart do
on roles(:app) do
execute "cd #{current_path} && RAILS_ENV=#{fetch(:stage)} bundle exec pumactl -S #{shared_path}/pids/puma.state restart"
end
end
desc "Status of the application"
task :status do
on roles(:app) do
execute "cd #{current_path} && RAILS_ENV=#{fetch(:stage)} bundle exec pumactl -S #{shared_path}/pids/puma.state stats"
end
end
end
after "deploy", "deploy:restart"
after "deploy", "deploy:cleanup"
Now I did bundle exec cap production deploy. And after huge log I got the below error.
DEBUG [cced60a1] bash: bundle: command not found
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host <ip-snipped>: cd /home/ubuntu/gobgob-ror/current && RAILS_ENV=production bundle exec pumactl -S /home/ubuntu/gobgob-ror/shared/pids/puma.state restart exit status: 127
cd /home/ubuntu/gobgob-ror/current && RAILS_ENV=production bundle exec pumactl -S /home/ubuntu/gobgob-ror/shared/pids/puma.state restart stdout: bash: bundle: command not found
cd /home/ubuntu/gobgob-ror/current && RAILS_ENV=production bundle exec pumactl -S /home/ubuntu/gobgob-ror/shared/pids/puma.state restart stderr: Nothing written
SSHKit::Command::Failed: cd /home/ubuntu/gobgob-ror/current && RAILS_ENV=production bundle exec pumactl -S /home/ubuntu/gobgob-ror/shared/pids/puma.state restart exit status: 127
cd /home/ubuntu/gobgob-ror/current && RAILS_ENV=production bundle exec pumactl -S /home/ubuntu/gobgob-ror/shared/pids/puma.state restart stdout: bash: bundle: command not found
cd /home/ubuntu/gobgob-ror/current && RAILS_ENV=production bundle exec pumactl -S /home/ubuntu/gobgob-ror/shared/pids/puma.state restart stderr: Nothing written
Tasks: TOP => deploy:restart
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing on host <ip-snipped>: cd /home/ubuntu/gobgob-ror/current && RAILS_ENV=production bundle exec pumactl -S /home/ubuntu/gobgob-ror/shared/pids/puma.state restart exit status: 127
cd /home/ubuntu/gobgob-ror/current && RAILS_ENV=production bundle exec pumactl -S /home/ubuntu/gobgob-ror/shared/pids/puma.state restart stdout: bash: bundle: command not found
cd /home/ubuntu/gobgob-ror/current && RAILS_ENV=production bundle exec pumactl -S /home/ubuntu/gobgob-ror/shared/pids/puma.state restart stderr: Nothing written
[arup#gobgob-ror (master)]$
Looks like the bundler gem is not installed on your server. It should be installed and the bundle executable should be available in $PATH.
Try executing the bundle --version directly on the server to ascertain that bundler is actually missing.
If that is case, install the bundler gem and you should be good to go. Or to actually keep things automated you can define a capistrano task to check if the bundle executable is available or not and install the bundler gem if it is not available. You can execute this task before the bundler:install task.
UPDATE : If you are using some ruby manager like rvm or chruby or anything like that, the bundle executable might not be available to your Capistrano deploy task. In that case you have to make sure your deploy task gets a login shell so that all those shell scripts are executed.
Here is what I have now which resolved the issue. I got help from Rustam A. Gasanov to make it working. Thanks a lot!!
deploy.rb
# config valid only for current version of Capistrano
lock '3.4.0'
set :stage, 'production'
set :application, "gobgob-ror"
set :repo_url, 'git#github.com:narhamah/gobgob-ror.git'
set :rvm_type, :user
set :rvm_ruby_version, 'ruby-2.2.2#gobgob'
set :rvm_binary, '~/.rvm/bin/rvm'
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, '/home/ubuntu/gobgob-ror'
# Default value for :scm is :git
set :scm, :git
set :branch, "master"
#set :user, "ubuntu"
set :use_sudo, false
set :rails_env, "production"
set :deploy_via, :remote_cache
set :ssh_options, { user: 'ubuntu', :forward_agent => true, :port => 22, keys: ["#{ENV['HOME']}/.ssh/id_rsa"]}
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
# set :log_level, :debug
# Default value for :pty is false
set :pty, true
server "xx.xx.xxx.xxx", roles: [:app, :web, :db], :primary => true
set :normalize_asset_timestamps, %{public/images public/javascripts public/stylesheets}
# Default value for :linked_files is []
set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
# Default value for linked_dirs is []
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
set :keep_releases, 5
namespace :deploy do
desc "Start the application"
task :start do
on roles(:app) do
execute "cd #{current_path} && RAILS_ENV=#{fetch(:stage)} #{fetch(:rvm_binary)} #{fetch(:rvm_ruby_version)} do bundle exec puma -b 'unix://#{shared_path}/sockets/puma.sock' -S #{shared_path}/sockets/puma.state --control 'unix://#{shared_path}/sockets/pumactl.sock' >> #{shared_path}/log/puma-#{fetch(:stage)}.log 2>&1 &", :pty => false
end
end
desc "Stop the application"
task :stop do
on roles => :app do
execute "cd #{current_path} && RAILS_ENV=#{fetch(:stage)} #{fetch(:rvm_binary)} #{fetch(:rvm_ruby_version)} do bundle exec pumactl -S #{shared_path}/pids/puma.state stop"
end
end
desc "Restart the application"
task :restart do
on roles(:app) do
execute "cd #{current_path} && RAILS_ENV=#{fetch(:stage)} #{fetch(:rvm_binary)} #{fetch(:rvm_ruby_version)} do bundle exec pumactl -S #{shared_path}/pids/puma.state restart"
end
end
desc "Status of the application"
task :status do
on roles(:app) do
execute "cd #{current_path} && RAILS_ENV=#{fetch(:stage)} #{fetch(:rvm_binary)} #{fetch(:rvm_ruby_version)} do bundle exec pumactl -S #{shared_path}/pids/puma.state stats"
end
end
end
after "deploy", "deploy:restart"
after "deploy", "deploy:cleanup"
Last output which confirmed it works..
INFO [12d4a428] Running /usr/bin/env cd /home/ubuntu/gobgob-ror/current && RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.2.2#gobgob do bundle exec pumactl -S /home/ubuntu/gobgob-ror/shared/pids/puma.state restart on xx.xx.xxx.xxx
DEBUG [12d4a428] Command: cd /home/ubuntu/gobgob-ror/current && RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.2.2#gobgob do bundle exec pumactl -S /home/ubuntu/gobgob-ror/shared/pids/puma.state restart
DEBUG [12d4a428] Command restart sent success
DEBUG [12d4a428]
INFO [12d4a428] Finished in 1.379 seconds with exit status 0 (successful).
[arup#gobgob-ror (master)]$
Related
I'm using Capistrano for deploying my Rails app. and now Im facing error below when I enter commandcap production deploy` :
✔ 02 deploy#82.196.13.29 0.475s
04:44 webpacker:precompile
01 $HOME/.rbenv/bin/rbenv exec bundle exec rails webpacker:clobber
(Backtrace restricted to imported tasks)
cap aborted!
Errno::ENOENT: No such file or directory - ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.5" RAILS_ENV="production" RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.5" RAILS_ENV="production" ; $HOME/.rbenv/bin/rbenv exec bundle exec rails webpacker:clobber )
Tasks: TOP => webpacker:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: No such file or directory - ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.5" RAILS_ENV="production" RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.5.5" RAILS_ENV="production" ; $HOME/.rbenv/bin/rbenv exec bundle exec rails webpacker:clobber )
And this is my deploy.rb file:
lock "~> 3.11.0"
set :application, "appName"
set :repo_url, "git#github.com:githubusername/appName"
# Deploy to the user's home directory
set :deploy_to, "/home/deploy/#{fetch :application}"
set :default_env, {
'RBENV_ROOT' => '$HOME/.rbenv',
'RBENV_VERSION' => '2.5.5',
'RAILS_ENV' => 'production'
}
append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', '.bundle', 'public/system', 'public/uploads'
# Only keep the last 5 releases to save disk space
set :keep_releases, 5
before "deploy:assets:precompile", "deploy:yarn_install"
namespace :deploy do
desc 'Run rake yarn:install'
task :yarn_install do
on roles(:web) do
within release_path do
execute("cd #{release_path} && yarn install")
end
end
end
end
after 'deploy:updated', 'webpacker:precompile'
I'm using Rails 5.2.3 and Ruby 2.5.5 in this application. I also have a file .rbenv in /home/deploy/appName and contains these variables:
RAILS_MASTER_KEY=ohai
SECRET_KEY_BASE=1234567890
STRIPE_PUBLIC_KEY=x
STRIPE_PRIVATE_KEY=y
How can I fix this problem?
I am using this_link for deploying, but I didnt created new user rather I am continuing with root user. I am using unicorn, nginx, capistrano for this.
On running cap deploy:cold, I am getting error bash: bundle: command not found.
deploy.rb
set :stages, %w(production) #various environments
require "bundler/capistrano"
require "rvm/capistrano"
server "xxx.xxx.xxx.xx", :web, :app, :db, primary: true
set :application, "xyz"
set :stage, "production"
set :user, "root"
set :port, 22
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :default_shell, :bash
# set :scm, "git"
set :repository, "git#bitbucket.org:xyz_app/xyz.git"
set :branch, "master"
# set :rvm_ruby_string, :local # use the same ruby as used locally for deployment
set :rvm_autolibs_flag, "read-only" # more info: rvm help autolibs
before 'deploy:setup', 'rvm:install_rvm' # install/update RVM
# before 'deploy:setup', 'rvm:install_ruby'
# before 'deploy:setup', 'rvm:install_ruby' # install Ruby and create gemset,
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:cleanup" # keep only the last 5 releases
namespace :deploy do
%w[start stop restart].each do |command|
desc "#{command} unicorn server"
task command, roles: :app, except: {no_release: true} do
run "/etc/init.d/unicorn_#{application} #{command}"
end
end
task :setup_config, roles: :app do
sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
run "mkdir -p #{shared_path}/config"
put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
puts "Now edit the config files in #{shared_path}."
end
after "deploy:setup", "deploy:setup_config"
task :symlink_config, roles: :app do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
after "deploy:finalize_update", "deploy:symlink_config"
desc "Make sure local git is in sync with remote."
task :check_revision, roles: :web do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
before "deploy", "deploy:check_revision"
end
cap shell output
cap> echo $PATH
[establishing connection(s) to xxx.xxx.xxx.xx]
** [out :: xxx.xxx.xxx.xx] /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/root/.rvm/bin
** [out :: xxx.xxx.xxx.xx]
cap> id
** [out :: xxx.xxx.xxx.xx] uid=0(root) gid=0(root) groups=0(root)
** [out :: xxx.xxx.xxx.xx]
cap> exit
cap deploy:check
You appear to have all necessary dependencies installed
Error code
* 2015-09-10 01:49:10 executing `bundle:install'
* executing "cd /home/root/apps/xyz/releases/20150909201909 && bundle install --gemfile /home/root/apps/xyz/releases/20150909201909/Gemfile --path /home/root/apps/xyz/shared/bundle --deployment --quiet --without development test"
servers: ["xxx.xxx.xxx.xx"]
[xxx.xxx.xxx.xx] executing command
** [out :: xxx.xxx.xxx.xx] bash: bundle: command not found
** [out :: xxx.xxx.xxx.xx]
command finished in 338ms
*** [deploy:update_code] rolling back
Please help me out from this issue. Thanks in advance
You need bundler. http://bundler.io/
gem install bundler
This gave it away: bash: bundle: command not found
I'm attempting to deploy my with Capistrano 3, but failed.
It returned such a error:
** Invoke deploy:symlink:shared (first_time)
** Execute deploy:symlink:shared
** Invoke deploy:symlink:linked_files (first_time)
** Execute deploy:symlink:linked_files
** Invoke deploy:symlink:linked_dirs (first_time)
** Execute deploy:symlink:linked_dirs
INFO[8051297e] Running /usr/bin/env mkdir -pv /home/wango/apps/wango/releases/20140929084104/public on 101.227.244.212
INFO[b6759259] Running /usr/bin/env mkdir -pv /home/wango/apps/wango/releases/20140929084104/public on wango.cc
INFO[8051297e] Finished in 0.024 seconds with exit status 0 (successful).
INFO[b6759259] Finished in 0.025 seconds with exit status 0 (successful).
INFO[871fe15d] Running /usr/bin/env ln -s /home/wango/apps/wango/shared/public/assets /home/wango/apps/wango/releases/20140929084104/public/assets on 101.227.244.212
INFO[bca7add7] Running /usr/bin/env ln -s /home/wango/apps/wango/shared/public/assets /home/wango/apps/wango/releases/20140929084104/public/assets on wango.cc
INFO[871fe15d] Finished in 0.023 seconds with exit status 0 (successful).
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host wango.cc: ln exit status: 1
ln stdout: Nothing written
ln stderr: ln: failed to create symbolic link ‘/home/wango/apps/wango/releases/20140929084104/public/assets/assets’: File exists
In my releases folder, there are more than one 'assets' folders:
/releases/20140929084104/public/assets/assets
How can I fixed it?
And this is my deploy.rb:
# config valid only for Capistrano 3.1
lock '3.2.1'
set :application, 'wango'
set :repo_url, 'git#bitbucket.org:jofone/wango.git'
set :branch, 'master'
set :user, 'wango'
set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
set :scm, :git
set :format, :pretty
set :log_level, :info
set :pty, true
# set :linked_files, %w{config/database.yml config/app_config.yml}
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
set :keep_releases, 5
namespace :deploy do
desc "Check that we can access everything"
task :check_write_permissions do
on roles(:all) do |host|
if test("[ -w #{fetch(:deploy_to)} ]")
info "#{fetch(:deploy_to)} is writable on #{host}"
else
error "#{fetch(:deploy_to)} is not writable on #{host}"
end
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
sudo "service #{fetch(:application)}_server restart"
sudo "service nginx restart"
end
end
after :publishing, :restart
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
# namespace :assets do
# before :backup_manifest, 'deploy:assets:create_manifest_json'
# task :create_manifest_json do
# on roles :web do
# within release_path do
# execute :mkdir, release_path.join('assets_manifest_backup')
# end
# end
# end
# end
set :puma_rackup, -> { File.join(current_path, 'config.ru') }
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_error.log"
set :puma_error_log, "#{shared_path}/log/puma_access.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
set :puma_threads, [0, 16]
set :puma_workers, 0
set :puma_init_active_record, true
set :puma_preload_app, true
I deploying rails project using capistrano 3.0
ror + nginx + unicorn
deploy is so not bad.
but server died during unicorn restart time.
1~2 second died server..
I dont know what i todo..
this is my deploy.rb source..
# -*- encoding : utf-8 -*-
# config valid only for Capistrano 3.1
lock '3.1.0'
require 'unicorn'
#set :whenever_command, "bundle exec whenever"
#require "whenever/capistrano"
set :application, 'projectname'
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
# Default deploy_to directory is /var/www/my_app
# set :deploy_to, '/var/www/my_app'
# Default value for :scm is :git
set :scm, :git
set :repo_url, 'git#github.com:gitURL'
# Default value for :format is :pretty
set :branch, 'master'
set :deploy_via, :remote_cache
# set :format, :pretty
# Default value for :log_level is :debug
# set :log_level, :debug
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
# set :linked_files, %w{config/database.yml}
# Default value for linked_dirs is []
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
# Default value for default_env is {}
set :default_env, { path: "/root/.rbenv/versions/2.1.0/lib/ruby/gems:/root/.rbenv/versions/2.1.0/bin:$PATH" }
#set :current_deploy_path, "DEPLOY_PATH"
# Default value for keep_releases is 5
# set :keep_releases, 5
set :ssh_options, { :forward_agent => true}
set :user, "user"
set :password, "passwod"
namespace :whenever do
task :start do
on roles(:app) do
execute("cd #{fetch :current_deploy_path}")
within release_path do
with rails_env: fetch(:rails_env) do
execute :bundle, 'exec whenever --update-crontab'
end
end
end
end
end
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
# execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, :restart
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
before 'deploy:assets:precompile', :link_assets
task :link_assets do
on roles(:app), :roles => :app, :except => { :no_release => true } do
execute("ln -fs #{shared_path}/database.yml #{release_path}/config/database.yml")
end
end
#before 'deploy:publishing', :kill_unicorns
task :kill_unicorns do
on roles(:app), in: :sequence, wait: 3 do
execute("if [ -f #{fetch :current_deploy_path}/tmp/pids/unicorn.pid ]; then kill -s QUIT `cat #{fetch :current_deploy_path}/tmp/pids/unicorn.pid`; fi")
end
end
task :make_unicorn do
on roles(:app), in: :sequence, wait: 3 do
execute :mkdir, '-p', "#{fetch :current_deploy_path}/tmp/pids"
execute("cd #{fetch :current_deploy_path}")
execute("if [ -f #{shared_path}/unicorn.pid ]; then kill -s QUIT `cat #{shared_path}/unicorn.pid`; fi")
within release_path do
with rails_env: fetch(:rails_env) do
execute :bundle, 'exec unicorn -D -c config/unicorn.rb -E production'
end
end
execute("cp #{fetch :current_deploy_path}/tmp/pids/unicorn.pid #{shared_path}/unicorn.pid")
end
end
# desc "Update the crontab file"
# task :update_crontab do #, :roles => :db do
# on roles(:app), in: :sequence, wait: 3 do
# execute("cd #{release_path} && bundle exec whenever --update-crontab #{application}")
# end
# end
# after 'deploy:publishing', :kill_unicorns
after 'deploy:publishing', :make_unicorn
after 'deploy:finishing', 'whenever:start'
end
and this is my deploy/production.rb
set :domain, "14.63.165.216"
set :rails_env, "production"
set :current_deploy_path, "/geuinea_pig/priday/current"
# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server
# definition into the server list. The second argument
# something that quacks like a hash can be used to set
# extended properties on the server.
server '14.63.165.216', user: 'root', roles: %w{web app db}, primary: true#, my_property: :my_value
set :deploy_to, '/geuinea_pig/priday'
set :ssh_options, {
user: 'root', # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
forward_agent: false,
#auth_methods: %w(publickey password),
auth_methods: %w(password),
password: 'dPffhdPffh1!'
}
this is deploy log in capistrano log
INFO [193203be] Running /usr/bin/env if [ -f /path/shared/unicorn.pid ]; then kill -s QUIT `cat /path/shared/unicorn.pid`; fi on 14.63.165.216
DEBUG [193203be] Command: if [ -f /path/shared/unicorn.pid ]; then kill -s QUIT `cat /path/shared/unicorn.pid`; fi
#---------------------------------
#THIS TIME DIED SERVER 2~3 second
#---------------------------------
INFO [193203be] Finished in 0.227 seconds with exit status 0 (successful).
DEBUG [05a0c865] Running /usr/bin/env if test ! -d /path/releases/20140706164800; then echo "Directory does not exist '/path/releases/20140706164800'" 1>&2; false; fi on 14.63.165.216
DEBUG [05a0c865] Command: if test ! -d /path/releases/20140706164800; then echo "Directory does not exist '/path/releases/20140706164800'" 1>&2; false; fi
DEBUG [05a0c865] Finished in 0.229 seconds with exit status 0 (successful).
INFO [3cf3c052] Running /usr/bin/env bundle exec unicorn -D -c config/unicorn.rb -E production on 14.63.165.216
DEBUG [3cf3c052] Command: cd /path/releases/20140706164800 && ( PATH=/root/.rbenv/versions/2.1.0/lib/ruby/gems:/root/.rbenv/versions/2.1.0/bin:$PATH RAILS_ENV=production /usr/bin/env bundle exec unicorn -D -c config/unicorn.rb -E production )
INFO [3cf3c052] Finished in 1.061 seconds with exit status 0 (successful).
INFO [07718210] Running /usr/bin/env cp /path/current/tmp/pids/unicorn.pid /path/shared/unicorn.pid on 14.63.165.216
DEBUG [07718210] Command: cp /path/current/tmp/pids/unicorn.pid /path/shared/unicorn.pid
INFO [07718210] Finished in 0.197 seconds with exit status 0 (successful).
I would suggest a slower start on Capistrano, if you're new to it? I find it challenging. In fact, I think you're way beyond me. There are so many little things that can go wrong and the logs/output can be a bit overwhelming that I try some simpler cap tasks. I create a weird directory under the home of my deployer user and then run this:
task :dir_exists do
ask(:dir_to_test, "$home")
on roles(:all) do |host|
if test("[ -d #{fetch(:dir_to_test)} ]")
info "Phew, it's ok, the directory exists!"
else
info "Directory #{fetch(:dir_to_test)} does not exist"
end
end
end
If that runs, at least I know that I'm communicating with the server and can run things. I had big problems at first mostly having to do with the authentication. I didn't get the whole ssh-add thing. Even yesterday I had to run some new commands on my database and it took me a about two hours to figure out that my syntax was complete crap.
Anyway, the more specific you can be about what is going wrong, the more help that will be offered. By the way, do you really have a top-level directory called "/geuinea_pig/friday/current"? If all of this is capistrano, maybe save these files off and start simpler? I say that because my deploy is alot simpler, maybe you don't need all that? Also, won't backtick execution happen on the local machine (you have backtick cat /path/shared/unicorn.pid backtick)?
Anyway, good luck!
"rake assets:precompile" and "cap deploy" consume extremely high amount of time whenever I call it (usually more then an hour). Sometimes deploy hang at all.
I use Rails 3.2.13, Ruby 1.9.3, OSX and Backbone's Chaplin Framework for frontend.
How can I speed up assets precompile and deploy task and what can cause such freezing?
My deploy.rb config:
# -*- encoding : utf-8 -*-
require 'bundler/capistrano'
load 'deploy/assets'
set :application, "eyelashes"
set :rails_env, "production"
set :repository, "git#github.com:eyelasher/repo.git"
set :scm, :git
set :deploy_via, :checkout
set :ssh_options, { :forward_agent => true }
default_run_options[:pty] = true
server "75.223.145.3", :app, :web, :db, :primary => true
set :bundle_without, [:test]
set :user, 'deployer'
set :deploy_to, "/home/deployer/eyelasher"
set :branch, "master" unless exists?(:branch)
set :use_sudo, false
set :rvm_type, :user
set :rvm_ruby_string, :local
set :deploy_via, :checkout
before 'deploy:setup', 'rvm:create_gemset'
set :unicorn_conf, "#{deploy_to}/current/config/unicorn.rb"
set :unicorn_pid, "#{deploy_to}/shared/pids/unicorn.pid"
after "deploy", "deploy:migrate"
after "deploy", "deploy:cleanup"
require 'rvm/capistrano'
require 'thinking_sphinx/deploy/capistrano'
#after 'deploy:update_code', :roles => :app do
#run "rm -f #{current_release}/config/database.yml"
#run "ln -s #{deploy_to}/shared/config/database.yml #{current_release}/config/database.yml"
#end
namespace :deploy do
task :restart do
run "if [ -f #{unicorn_pid} ]; then kill -USR2 `cat #{unicorn_pid}`; else cd #{deploy_to}/current && bundle exec unicorn -c #{unicorn_conf} -E #{rails_env} -D; fi"
end
task :start do
run "cd #{deploy_to}/current && bundle exec unicorn -c #{unicorn_conf} -E #{rails_env} -D;"
end
task :stop do
run "if [ -f #{unicorn_pid} ] && [ -e /proc/$(cat #{unicorn_pid}) ]; then kill -QUIT `cat #{unicorn_pid}`; fi"
end
end
# Thinking Sphinx typing shortcuts
namespace :ts do
task :conf do
thinking_sphinx.configure
end
task :in do
thinking_sphinx.index
end
task :start do
thinking_sphinx.start
end
task :stop do
thinking_sphinx.stop
end
task :restart do
thinking_sphinx.restart
end
task :rebuild do
thinking_sphinx.rebuild
end
end
# http://github.com/jamis/capistrano/blob/master/lib/capistrano/recipes/deploy.rb
# :default -> update, restart
# :update -> update_code, symlink
namespace :deploy do
desc "Link up Sphinx's indexes."
task :symlink_sphinx_indexes, :roles => [:app] do
run "ln -nfs #{shared_path}/db/sphinx #{release_path}/db/sphinx"
end
task :activate_sphinx, :roles => [:app] do
symlink_sphinx_indexes
thinking_sphinx.configure
#thinking_sphinx.stop
#thinking_sphinx.start
end
task :copy_images do
run "cp -R #{shared_path}/public/images #{release_path}/public/images"
end
before 'deploy:update_code', 'thinking_sphinx:stop'
after 'deploy:update_code', 'deploy:activate_sphinx'
after 'deploy:update_code', 'deploy:copy_images'
end
Maybe I can speedup somehow by making changes in deploy configuration?
If you are deploying to a memory constrained VPS that sounds plausible. I'd recommend precompiling the assets on a a faster machine and checking them in to your repository.
There are various Gems and packages for speeding up asset precompilation by parallesing them, however in your situation that will likely make things MUCH worse!