【问题标题】:capistrano shared/bin folder is emptycapistrano 共享/bin 文件夹为空
【发布时间】:2015-04-09 12:08:06
【问题描述】:

我正在使用 capistrano 进行部署,由于某种原因,我的 shared/bin 文件夹是空的,而且它应该包含 -rails、rake、bundle、setup、spring。现在显然我做错了什么,但由于我是 capistrano 的新手,我不知道它是什么,因为它在我的 git 存储库中,据我所知,它从存储库中复制了整个内容。因为我不确定它是否相关,所以我将把我更改的所有内容都放在 capistrano 部署中。 这是我的 deploy.rb

lock '3.4.0'
# application settings
set :application, 'SomeApplication'
set :user, 'someuser'
#set :repo_url, 'git@bitbucket.org:someapp/someappserver.git'
set :rails_env, 'production'
set :use_sudo, false
set :keep_releases, 5


#git settings
set :scm,           :git
set :branch,        "master"
set :repo_url,    "git@bitbucket.org:someapplication/someapplicationserver.git"
set :deploy_via,    :remote_cache


set :rvm_ruby_version, '2.2.1'
set :default_env, { rvm_bin_path: '~/.rvm/bin' }
SSHKit.config.command_map[:rake] = "#{fetch(:default_env)[:rvm_bin_path]}/rvm ruby-#{fetch(:rvm_ruby_version)} do bundle exec rake"


# dirs we want symlinked to the shared folder
# during deployment
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}


set :pg_database, "someapp_production"
set :pg_user, "someapp_production"
set :pg_ask_for_password, true


namespace :deploy do

  task :config_nginx do
    pre = File.basename(previous_release)
    cur = File.basename(release_path)
    run "#{sudo} sed 's/#{pre}/#{cur}/g' /etc/nginx/sites-available/default"
  end

  task :restart_thin_server do
    run "cd #{previous_release}; source $HOME/.bash_profile && thin stop -C thin_config.yml"
    run "cd #{release_path}; source $HOME/.bash_profile && thin start -C thin_config.yml"
  end

  task :restart_nginx do
    run "#{sudo} service nginx restart"
  end


  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')
      #
      # The capistrano-unicorn-nginx gem handles all this
      # for this example
    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

这是我的 deploy/production.rb

# production deployment
set :stage, :production
# use the master branch of the repository
set :branch, "master"
# the user login on the remote server
# used to connect and deploy
set :deploy_user, "someuser"
# the 'full name' of the application
set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}"
# the server(s) to deploy to
server 'someserver.cloudapp.net', user: 'someuser', roles: %w{web app db}, primary: true
# the path to deploy to
set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:full_app_name)}"
# set to production for Rails
set :rails_env, :production

这是我的 cap 文件

require 'capistrano/setup'

# Include default deployment tasks
require 'capistrano/deploy'

# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
#   https://github.com/capistrano/rvm
#   https://github.com/capistrano/rbenv
#   https://github.com/capistrano/chruby
#   https://github.com/capistrano/bundler
#   https://github.com/capistrano/rails
#   https://github.com/capistrano/passenger
#
 require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
 require 'capistrano/bundler'
 require 'capistrano/rails/assets'
 require 'capistrano/rails/migrations'
# require 'capistrano/passenger'

require 'capistrano/thin'
require 'capistrano/postgresql'

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

【问题讨论】:

  • 你的 repo 中有 bin/ 下的所有必需文件吗?
  • 不,没有 rails.rb 它无法启动 - 我可以复制它,但那将是一个糟糕的解决方案。
  • 我也有同样的问题。我在这里找到了答案:stackoverflow.com/questions/28243043/…

标签: ruby-on-rails ruby-on-rails-4 capistrano3


【解决方案1】:

就像@emj365 说的
只需从 config/deploy.rb 中的 linked_dirs 中删除 bin

set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

【讨论】:

  • 您能解释一下为什么您从linked_dirs 中删除了bin。它对我有用,但我想了解原因。
  • linked_dirs 未部署。对日志(您不想部署本地日志)、tmp/cache(您不想部署本地缓存)等很有用...
【解决方案2】:

@gilmishal 请检查此链接.. capistrano-deploy-configuration

并密切关注我多次出错的目录路径

# Default deploy_to directory is /var/www/my_app_name
# set :deploy_to, '/var/www/my_app_name'  # This conf is by default 

希望能解决你的问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-04
    • 1970-01-01
    • 2022-06-30
    • 2013-07-07
    • 2016-05-29
    • 2020-09-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多