Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 capistrano权限被拒绝cap上的错误:安装程序_Ruby On Rails 3_Deployment_Capistrano_Setup Deployment_Unicorn - Fatal编程技术网

Ruby on rails 3 capistrano权限被拒绝cap上的错误:安装程序

Ruby on rails 3 capistrano权限被拒绝cap上的错误:安装程序,ruby-on-rails-3,deployment,capistrano,setup-deployment,unicorn,Ruby On Rails 3,Deployment,Capistrano,Setup Deployment,Unicorn,我试图用capistrano nginx和unicorn部署一个简单的应用程序 /srv/paints.git(发起和推动回购) /srv/绘画(应安装应用程序的地方) My deploy.rb看起来像 # config/deploy.rb require "bundler/capistrano" set :scm, :git set :repository, "git@109.0.0.0.05:srv/paintings.git" set :bra

我试图用capistrano nginx和unicorn部署一个简单的应用程序

  • /srv/paints.git(发起和推动回购)

  • /srv/绘画(应安装应用程序的地方)

My deploy.rb看起来像

  # config/deploy.rb 
require "bundler/capistrano"

set :scm,             :git
set :repository,      "git@109.0.0.0.05:srv/paintings.git"
set :branch,          "origin/master"
set :migrate_target,  :current
set :ssh_options,     { :forward_agent => true }
set :rails_env,       "production"
set :deploy_to,       "/srv/paintings"
set :normalize_asset_timestamps, false

set :user,            "root"
set :group,           "rvm"
set :use_sudo,        true

role :web,    "109.0.0.0.05"
role :app,    "109.0.0.0.05"
role :db,     "109.0.0.0.05", :primary => true

set(:latest_release)  { fetch(:current_path) }
set(:release_path)    { fetch(:current_path) }
set(:current_release) { fetch(:current_path) }

set(:current_revision)  { capture("cd #{current_path}; git rev-parse --short HEAD").strip }
set(:latest_revision)   { capture("cd #{current_path}; git rev-parse --short HEAD").strip }
set(:previous_revision) { capture("cd #{current_path}; git rev-parse --short HEAD@{1}").strip }

default_environment["RAILS_ENV"] = 'production'
default_run_options[:shell] = 'bash'

namespace :deploy do
  desc "Deploy your application"
  task :default do
    update
    restart
  end

  desc "Setup your git-based deployment app"
  task :setup, :except => { :no_release => true } do
    dirs = [deploy_to, shared_path]
    dirs += shared_children.map { |d| File.join(shared_path, d) }
    run "#{try_sudo} mkdir -p #{dirs.join(' ')} && #{try_sudo} chmod g+w #{dirs.join(' ')}"
    run "git clone #{repository} #{current_path}"
  end

  task :cold do
    update
    migrate
  end

  task :update do
    transaction do
      update_code
    end
  end

  desc "Update the deployed code."
  task :update_code, :except => { :no_release => true } do
    run "cd #{current_path}; git fetch origin; git reset --hard #{branch}"
    finalize_update
  end

  desc "Update the database (overwritten to avoid symlink)"
  task :migrations do
    transaction do
      update_code
    end
    migrate
    restart
  end

  task :finalize_update, :except => { :no_release => true } do
    run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)

    # mkdir -p is making sure that the directories are there for some SCM's that don't
    # save empty folders
    run <<-CMD
      rm -rf #{latest_release}/log #{latest_release}/public/system #{latest_release}/tmp/pids &&
      mkdir -p #{latest_release}/public &&
      mkdir -p #{latest_release}/tmp &&
      ln -s #{shared_path}/log #{latest_release}/log &&
      ln -s #{shared_path}/system #{latest_release}/public/system &&
      ln -s #{shared_path}/pids #{latest_release}/tmp/pids &&
      ln -sf #{shared_path}/database.yml #{latest_release}/config/database.yml
    CMD

    if fetch(:normalize_asset_timestamps, true)
      stamp = Time.now.utc.strftime("%Y%m%d%H%M.%S")
      asset_paths = fetch(:public_children, %w(images stylesheets javascripts)).map { |p| "#{latest_release}/public/#{p}" }.join(" ")
      run "find #{asset_paths} -exec touch -t #{stamp} {} ';'; true", :env => { "TZ" => "UTC" }
    end
  end

  desc "Zero-downtime restart of Unicorn"
  task :restart, :except => { :no_release => true } do
    run "kill -s USR2 `cat /tmp/unicorn.my_site.pid`"
  end

  desc "Start unicorn"
  task :start, :except => { :no_release => true } do
    run "cd #{current_path} ; bundle exec unicorn_rails -c config/unicorn.rb -D"
  end

  desc "Stop unicorn"
  task :stop, :except => { :no_release => true } do
    run "kill -s QUIT `cat /tmp/unicorn.my_site.pid`"
  end  

  namespace :rollback do
    desc "Moves the repo back to the previous version of HEAD"
    task :repo, :except => { :no_release => true } do
      set :branch, "HEAD@{1}"
      deploy.default
    end

    desc "Rewrite reflog so HEAD@{1} will continue to point to at the next previous release."
    task :cleanup, :except => { :no_release => true } do
      run "cd #{current_path}; git reflog delete --rewrite HEAD@{1}; git reflog delete --rewrite HEAD@{1}"
    end

    desc "Rolls back to the previously deployed version."
    task :default do
      rollback.repo
      rollback.cleanup
    end
  end
end

def run_rake(cmd)
  run "cd #{current_path}; #{rake} #{cmd}"
end

不要使用
default\u环境[“PATH”]=“-”
或以某种方式提供
bash
的完整路径(通常是
/bin/bash

当我告诉Capistrano连接到一个我以前从未连接过的ssh服务器时,我遇到了一个类似的错误。您是否尝试过仅使用
ssh连接服务器(使用相同的用户,即
root
而不是
git
)root@109.0.0.0.05

它可能会再次询问您是否要信任服务器。如果是这样,我猜Capistrano不会对您的“是”输入做出反应


此外,您还可以以root用户身份连接到服务器。这意味着您不需要将
use_sudo
设置为
true

检查生产机器中是否存在releases[/srv/paints/releases]文件夹。我认为您必须在production machine.thx中手动创建此文件夹。它不存在,尝试手动添加,但错误持续设置:use_sudo as false并尝试。Thx以前也尝试过,但没有成功。我不知道如何解决这个问题,它仍然悬而未决是的,最新的RVM,最新的ruby和最新的railsThx指出了一些显而易见的东西,我完全没有注意到这一点,尽管我已经看了好几次,但似乎还不够好。将该部分更改为“已发布更新”。但是问题仍然存在。由于这个问题已经解决,thx无法更新帖子。它似乎现在部署所有运行,但有一些小问题,它像独角兽,但猜测,这将不适合在这个赏金。还没有完全,我很可怕的卡在另一个部分,并考虑张贴一个问题,但这将是在另一个主题。谢谢
       [109.etc] env RAILS_ENV=production sh -c 'git clone git@109.etc:srv/paintings.git /srv/paintings/current'
 ** [out :: 109.etc] Initialized empty Git repository in /srv/paintings/current/.git/
 ** [out :: 109.etc] The authenticity of host '109.etc (109.etc)' can't be established.
 ** [out :: 109.etc] RSA key fingerprint is e9:af etc.
 ** [out :: 109.etc] Are you sure you want to continue connecting (yes/no)?

Typing Yes keeps me waiting forever with no status updates