无法修改冻结#<class:#<rake :: task:0x007f88ab1af578>&gt;在运行cap dev shell时

时间:2017-07-12 13:46:33

标签: capistrano

我正在尝试为新项目设置Capistrano,并在运行cap dev shell时收到以下错误。我在cap dev deploy上也遇到了同样的错误:check。我只想将bitbucket中的代码部署到一个具有一个特定角色的实例,我已经在deploy.rb中提到了

deploy.rb

set :application, "fex"
set :repo_url, "git@bitbucket.org:faasos/fex.git"

set :ec2_access_key_id,"AAAAAAAAAAA"
set :ec2_secret_access_key,"AAAAAAAAAAAAAAAAAAAAAA"
set :ec2_project_tag, 'Projects'
set :ec2_roles_tag, 'Roles'
set :ec2_stages_tag, 'Stages'
set :default_shell, "/usr/bin/bash"
set :shell, "bash"

set :keep_releases, 20

namespace :deploy do

  desc "run the frontend"
  task :seed do
    run "cd #{fetch(:deploy_to)}/current/code/fex/frontend; nohup puma RAILS_ENV=#{rails_env} &"
  end

  desc 'Restart application'
  task :restart do
    on roles(:fex), in: :sequence, wait: 5 do
      within "#{fetch(:deploy_to)}/current/" do
        # Your restart mechanism here
        begin
          #execute "fuser -k 3000/tcp"
        rescue =>e
          puts "[Error] e.to_s"
        end
       #execute "cd /home/ubuntu/code/fex/frontend && RAILS_ENV="development" nohup puma &"
        end
    end
  end
after :publishing, :restart

  after :restart, :clear_cache do
    on roles(:foodex), 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

dev.rb

require "cap-ec2/capistrano"

set :rails_env, :dev
set :branch, "master"
set :deploy_user, "ubuntu"
set :full_app_name, "fex"
set :deploy_to, "/home/#{fetch(:deploy_user)}/code/#{fetch(:full_app_name)}"

ec2_role :frontend,user: 'ubuntu'
ec2_role :samachar,user: 'ubuntu'
imohit:prod$ cap dev shell
WARNING: load:defaults has already been invoked and can no longer be modified.
Check that you haven't loaded a Capistrano plugin in deploy.rb by mistake.
Plugins must be loaded in the Capfile to initialize properly.
(Backtrace restricted to imported tasks)
cap aborted!
can't modify frozen #<Class:#<Rake::Task:0x007f88ab1af578>>

Tasks: TOP => dev
(See full trace by running task with --trace)
cap dev deploy:check
WARNING: load:defaults has already been invoked and can no longer be modified.
Check that you haven't loaded a Capistrano plugin in deploy.rb by mistake.
Plugins must be loaded in the Capfile to initialize properly.
(Backtrace restricted to imported tasks)
cap aborted!
can't modify frozen #<Class:#<Rake::Task:0x007f98992971b8>>

Tasks: TOP => dev
(See full trace by running task with --trace)

还剩下什么吗?

1 个答案:

答案 0 :(得分:0)

通过调用〜/ Capfile中的必需模块来解决这个问题:

require 'capistrano/bundler'
require "cap-ec2/capistrano"
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

Capistrano v3.10的Capfile包含这些作为潜在的设置配置。