Odkopię temat żeby nie robić nowego.
Chcę zrobić automatyczny deploy poprzez capistrano wraz z restartem aplikacji żeby od razu było widać zmiany.
Pierwszy problem może nie dotyczy dokładnie capistrano, ale ubuntu. Stworzyłem użytkownika “deploy”, któremu chcę nadać dokładnie takie same prawa jak ma “root”. W /etc/sudoers dodałem:
# User privilege specification
root ALL=(ALL:ALL) ALL
deploy ALL=(ALL:ALL) ALL
Niestety to nie do końca pomogło. W tej chwili jak chcę zrobić deploy dostaję:
[78.46.194.246] executing command
** [00.00.000.000 :: out] error: insufficient permission for adding an object to repository database .git/objects
** [00.00.000.000 :: out]
** [00.00.000.000 :: out]
** [00.00.000.000 :: out] fatal: failed to write object
** [00.00.000.000 :: out]
** [00.00.000.000 :: out] fatal: unpack-objects failed
** [00.00.000.000 :: out]
Postanowiłem więc spróbować za pomocą roota. Proces zostaje zabity, ale aplikacja nie wstaje:
[78.46.194.246] executing command
** [out :: 00.00.000.000] Could not find gem 'rails (~> 3.2.13)' in any of the gem sources listed in your Gemfile.
plik deploy.rb:
[code]set :application, “project”
set :repository, "git@github.com:qwerty/qwerty.git"
set :scm, :git
set :user, “root”
set :use_sudo, false
set :deploy_to, “/Apps/#{application}”
set :deploy_via, :remote_cache
set :normalize_asset_timestamps, false
ssh_options[:forward_agent] = true
default_run_options[:pty] = true
role :web, “00.00.000.000” # Your HTTP server, Apache/etc
role :app, “00.00.000.000” # This may be the same as your Web
server
role :db, “00.00.000.000”, :primary => true # This is where Rails migrations will run
set :rvm_ruby_string, ‘1.9.3-p125’
namespace :deploy do
namespace :app do
task :copy_config do
run “cp #{shared_path}/config/* #{current_release}/config/”
end
end
task :start do
run “cd #{current_path} && ./bin/app start”
end
task :stop do
run “cd #{current_path} && ./bin/app stop”
end
task :restart do
run “cd #{current_path} && ./bin/app restart”
end
end
after ‘deploy:finalize_update’, ‘deploy:app:copy_config’[/code]
plik app:
[code]#!/usr/bin/env ruby
require ‘yaml’
def start
system “bundle exec rails s -d -p3006”
end
def stop
pid = File.read(“tmp/pids/server.pid”).strip
system “kill -TERM #{pid}”
end
def restart
stop
start
end
case ARGV.first
when ‘start’
start
when ‘stop’
stop
when ‘restart’
restart
else
puts ‘start | stop | restart’
end[/code]
Serwer jest na ubuntu 12.04, nginx + thin
Będę wdzięczny za pomoc jak również inne uwagi dotyczące capistrano 