加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Capistrano:帽子流产!不知道如何构建任务’d

发布时间:2020-12-17 02:06:43 所属栏目:百科 来源:网络整理
导读:我正在使用capistrano 3.2.1将Rails 4.0应用程序部署到ubuntu服务器,但是当我尝试运行capistrano命令时,我收到错误. cap aborted!Don't know how to build task 'deploy:setup_config' 这是我试过的命令 cap production rvm:checkcap production deploy 这是
我正在使用capistrano 3.2.1将Rails 4.0应用程序部署到ubuntu服务器,但是当我尝试运行capistrano命令时,我收到错误.

cap aborted!
Don't know how to build task 'deploy:setup_config'

这是我试过的命令

cap production rvm:check
cap production deploy

这是我的deploy.rb文件

lock '3.2.1'

set :application,'app_name'
set :repo_url,'git@github.com:GITUSERNAME/REPO.git'

set :deploy_user,'deploy'
set :use_sudo,false

set :ssh_options,{:forward_agent => true,:keys => %w(/home/USER/.ssh/id_rsa)}

# Default branch is :master
# ask :branch,proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call

# Default deploy_to directory is /var/www/my_app
set :deploy_to,'/var/www/app_name'


 set :scm,:git
 set :scm_passphrase,""

 set :format,:pretty
 set :log_level,:debug

set :linked_files,%w{config/database.yml}

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

 set :keep_releases,5

set :tests,[]
set(:config_files,%w(
  nginx.config
  database.example.yml
  ))

set(:symlinks,[
  {
    source: "nginx.conf",link: "etc/nginx/sites-enabled/#{fetch(:full_app_name)}"
  }
  ])


namespace :deploy do
  before :deploy,"deploy:check_revision"
  before :deploy,"deploy:run_tests"
  before 'deploy:setup_config','nginx:remove_default_vhost' 

  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 'deploy:smylink:shared','deploy:compile_assets_locally'
  after :finishing,'deploy:cleanup'

  after 'deploy:setup_config','nginx:reload'
  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

这是我的Capfile.rb

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/rails'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

production.rb

set :stage,:production
set :branch,"master"
set :full_app_name,"#{fetch(:application)}_#{fetch(:stage)}"
set :server_name,"SERVERURL"
set :rails_env,:production
role :app,%w{deploy@example.com}
role :web,%w{deploy@example.com}
role :db,%w{deploy@example.com}
server 'SERVERURL',user: 'deploy',roles: %w{web app db},primary: :true

我知道capistrano中没有cap deploy:setup_config命令3.我做得对不对?

解决方法

你需要

cap deploy:setup

cap deploy:setup_config

结帐this了解更多信息

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读