How do I run a rake task from Capistrano?

前端 未结 16 2151
忘了有多久
忘了有多久 2020-11-28 02:18

I already have a deploy.rb that can deploy my app on my production server.

My app contains a custom rake task (a .rake file in the lib/tasks directory).

I\

16条回答
  •  猫巷女王i
    2020-11-28 02:47

    This worked for me:

    task :invoke, :command do |task, args|
      on roles(:app) do
        within current_path do
          with rails_env: fetch(:rails_env) do
            execute :rake, args[:command]
          end
        end
      end
    end
    

    Then simply run cap production "invoke[task_name]"

提交回复
热议问题