How do I run a rake task from Capistrano?

前端 未结 16 2113
忘了有多久
忘了有多久 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条回答
  •  一生所求
    2020-11-28 02:29

    Here's what I put in my deploy.rb to simplify running rake tasks. It's a simple wrapper around capistrano's run() method.

    def rake(cmd, options={}, &block)
      command = "cd #{current_release} && /usr/bin/env bundle exec rake #{cmd} RAILS_ENV=#{rails_env}"
      run(command, options, &block)
    end
    

    Then I just run any rake task like so:

    rake 'app:compile:jammit'
    

提交回复
热议问题