Source: Devato Technologies Blog

Devato Technologies Blog Run Custom Rake Takes on Server using Capistrano 3

If you've ever needed to run a custom rake command on the server, then you'll know how helpful it would be to run it along side your capistrano deployment process. Here's how:Add this to your deploy.rb:namespace :deploy do # .... # @example # bundle exec cap uat deploy:invoke task=users:update_defaults desc 'Invoke rake task on the server' task :invoke do fail 'no task provided' unless ENV['task'] on roles(:app) do within release_path do with rails_env: fetch(:rails_env) do execute :rake, ENV['task'] end end end end endThen you can run your command from the terminal:bundle exec cap uat deploy:invoke task=users:update_defaultsThe great thing about this is that if you are using capistrano/rbenv and capistrano/bundler, the execute command will automatically take care over everything for you under the hood.

Read full article »
Est. Annual Revenue
$100K-5.0M
Est. Employees
25-100
CEO Avatar

CEO

Update CEO

CEO Approval Rating

- -/100