2015-10-20 5 views
1

У меня возникла проблема при попытке развернуть мое приложение на хостинг через gem Capistrano. С авторизацией через SSH-ключи все в порядке. У меня есть следующая ошибка:SSHKit :: Runner :: ExecuteError Permission denied

(Backtrace restricted to imported tasks) 
cap aborted! 
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: scp: /tmp/yurta24/git-ssh.sh: Permission denied 
scp: /tmp/yurta24/git-ssh.sh: Permission denied 

Мой файл deploy.rb является:

lock '3.4.0' 

require 'net/ssh/proxy/http' 

sshproxy = Net::SSH::Proxy::HTTP.new('x.x.x.x', 8080) 
set :ssh_options, { :proxy => sshproxy } 

    application = 'yurta24' 
    login = 'yurta24' 
    $user = 'hosting_' + login 
    $server = 'calcium.locum.ru' 
    rvm_ruby_string = '2.1.5p273' 
    deploy_to = "/home/#{ $user }/projects/#{ application }" 
    unicorn_conf = "/etc/unicorn/#{ application }.#{ login }.rb" 
    unicorn_pid = "/var/run/unicorn/#{ $user }/#{ application }.#{ login }.pid" 
    unicorn_start_cmd = "(cd #{ deploy_to }/current; rvm use #{ rvm_ruby_string } do bundle exec unicorn_rails -DC#{ unicorn_conf })" 

    set :application, application 
    set :repo_url, "https://github.com/verrom/yurta24.git" 
    set :deploy_to, deploy_to 
    set :pty, true 
    set :default_env, { path: "/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin" } 

    namespace :deploy do 
    desc 'Restart application' 
    task :restart do 
    on roles(:app), in: :sequence, wait: 5 do 
    end 
    end 

    after :publishing, :restart 

    after :restart, :clear_cache do 
    on roles(:web), in: :groups, limit: 3, wait: 10 do 
    end 
    end 
end 

Мой файл production.rb является:

connect_to = "#{$user}@#{$server}" 
role :app, [connect_to] 
role :web, [connect_to] 
role :db, [connect_to] 
set :enable_ssl, true 

Полный список ошибка:

[email protected]:~/apps/yurta24$ cap production deploy:check 
DEBUG [b5b4061f] Running /usr/bin/env [ -d ~/.rvm ] as [email protected] 
DEBUG [b5b4061f] Command: [ -d ~/.rvm ] 
DEBUG [b5b4061f] Finished in 1.346 seconds with exit status 1 (failed). 
DEBUG [8c816727] Running /usr/bin/env [ -d /usr/local/rvm ] as [email protected] 
DEBUG [8c816727] Command: [ -d /usr/local/rvm ] 
DEBUG [8c816727] Finished in 0.180 seconds with exit status 0 (successful). 
DEBUG [a427409d] Running /usr/local/rvm/bin/rvm version as [email protected] 
DEBUG [a427409d] Command: (PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin /usr/local/rvm/bin/rvm version) 
DEBUG [a427409d] rvm 1.26.11 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] 
DEBUG [a427409d] Finished in 0.468 seconds with exit status 0 (successful). 
rvm 1.26.11 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] 
DEBUG [205f64d3] Running /usr/local/rvm/bin/rvm current as [email protected] 
DEBUG [205f64d3] Command: (PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin /usr/local/rvm/bin/rvm current) 
DEBUG [205f64d3] system 
DEBUG [205f64d3] Finished in 0.399 seconds with exit status 0 (successful). 
system 
DEBUG [730c9a49] Running /usr/local/rvm/bin/rvm default do ruby --version as [email protected] 
DEBUG [730c9a49] Command: (PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin /usr/local/rvm/bin/rvm default do ruby --version) 
DEBUG [730c9a49] ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu] 
DEBUG [730c9a49] Finished in 0.613 seconds with exit status 0 (successful). 
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu] 
INFO [4c8c1c1b] Running /usr/bin/env mkdir -p /tmp/yurta24/ as [email protected] 
DEBUG [4c8c1c1b] Command: (PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin /usr/bin/env mkdir -p /tmp/yurta24/) 
INFO [4c8c1c1b] Finished in 0.173 seconds with exit status 0 (successful). 
DEBUG Uploading /tmp/yurta24/git-ssh.sh 0.0% 
(Backtrace restricted to imported tasks) 
cap aborted! 
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: scp: /tmp/yurta24/git-ssh.sh: Permission denied 

scp: /tmp/yurta24/git-ssh.sh: Permission denied 

My Gemfile - это :

gem 'capistrano-rails' 
    gem 'capistrano-bundler' 
    gem 'capistrano-rvm' 
    gem 'capistrano-rbenv' 
    gem 'unicorn' 

список Вторая ошибка:

rake aborted! 
Cannot load `Rails.application.database_configuration`: 
Could not load database configuration. No such file - ["config/database.yml"] 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application/configuration.rb:110:in `database_configuration' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/railtie.rb:117:in `block (2 levels) in <class:Railtie>' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `each' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/base.rb:315:in `<module:ActiveRecord>' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/base.rb:26:in `<top (required)>' 
/home/hosting_yurta24/projects/yurta24/releases/20151020084626/config/initializers/dragonfly.rb:24:in `<top (required)>' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `load' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `block in load' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `load' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:652:in `block in load_config_initializer' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/notifications.rb:166:in `instrument' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:651:in `load_config_initializer' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:615:in `each' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:615:in `block in <class:Engine>' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `run' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:55:in `block in run_initializers' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `each' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `tsort_each_child' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:54:in `run_initializers' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:352:in `initialize!' 
/home/hosting_yurta24/projects/yurta24/releases/20151020084626/config/environment.rb:5:in `<top (required)>' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:328:in `require' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:328:in `require_environment!' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:457:in `block in run_tasks_blocks' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define' 
Could not load database configuration. No such file - ["config/database.yml"] 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application/configuration.rb:110:in `database_configuration' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/railtie.rb:117:in `block (2 levels) in <class:Railtie>' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `each' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/base.rb:315:in `<module:ActiveRecord>' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activerecord-4.2.4/lib/active_record/base.rb:26:in `<top (required)>' 
/home/hosting_yurta24/projects/yurta24/releases/20151020084626/config/initializers/dragonfly.rb:24:in `<top (required)>' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `load' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `block in load' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:268:in `load' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:652:in `block in load_config_initializer' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/notifications.rb:166:in `instrument' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:651:in `load_config_initializer' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:615:in `each' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:615:in `block in <class:Engine>' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `run' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:55:in `block in run_initializers' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `each' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `tsort_each_child' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/initializable.rb:54:in `run_initializers' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:352:in `initialize!' 
/home/hosting_yurta24/projects/yurta24/releases/20151020084626/config/environment.rb:5:in `<top (required)>' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:328:in `require' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:328:in `require_environment!' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/application.rb:457:in `block in run_tasks_blocks' 
/home/hosting_yurta24/projects/yurta24/shared/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define' 
Tasks: TOP => environment 
(See full trace by running task with --trace) 
rake stderr: Nothing written 

Tasks: TOP => deploy:assets:precompile 
(See full trace by running task with --trace) 
The deploy has failed with an error: Exception while executing as [email protected]: rake exit status: 1 

Спасибо.

+0

Вы можете указать ссылку на свой проект, чтобы я мог видеть ваши файлы capfile и unicorn – moeabdol

+0

@moeabdol https://github.com/verrom/yurta24.git – verrom

ответ

1

Поскольку это проблема разрешения, это может быть одна из многих вещей; Однако, убедитесь, что пользователь «hosting_yurta24» владеет каталогом/TMP

$ sudo chown hosting_yurta24 /tmp 

Это может быть потому, что когда you'v создал этот пользователь вы не присвоить ему административные привилегии.

Что касается вашей второй проблемы, то capistrano сообщает, что у вас нет файла database.yml на вашем VPS. Я также предполагаю, что у вас нет secrets.yml. Вот как вы их создаете:

Сначала убедитесь, что у вас есть эти два каталога. Если у вас их еще нет, создайте их:

/home/hosting_yurta24/projects/yurta24/shared/config 
/home/hosting_yurta24/projects/yurta24/log 

В первом каталоге будут храниться ваши проекты и базы данных. Второй каталог необходим, чтобы ваше приложение сохраняло свои журналы. Они оба должны быть там!

Теперь! CD в ​​/home/hosting_yurta24/projects/yurta24/shared/config и создать два файла

database.yml 
secrets.yml 

В database.yml вставьте следующее:

production: 
    adapter: postgresql    # if your using postgresql 
    encoding: unicode 
    pool: 5 
    timeout: 5000 
    database: yurta24_production  # database name 
    username: postgres     # database username 
    password: password     # database password 
    host: localhost 

Вернитесь на локальную машину, в каталог рельсы проекта и от типа терминала в:

rake secret 

Терминал должен сбрасывать длинную смесь строк и цифр. Это секрет вашего приложения. Скопируйте его, а затем на вас. VPS secrets.yml:

production: 
    secret_key_base: apsifq193uq8djf1jqe8er18jee9jd8eqeh8fqe8fqehh8qehfq # paste your secret here 

Надеюсь, это поможет.

+0

thats помог! Но у меня опять есть ошибка из предыдущего вопроса :) Я добавляю список ошибок к этому вопросу. Не могли бы вы посмотреть на него? – verrom

+0

I'v обновил ответ @verrom – moeabdol

+0

Спасибо большое! Это помогло !!! :) – verrom

Смежные вопросы