1

I am learning (by doing) Rails and Capistrano.

How can I execute a scrpit inside deploy.rb?

I came across run(command), exec(command), execute: or run:.

I don't have to specify :db or web so I have the following backbone:

task :myTask do
    on roles(:app) do 
      execute "bash myScript.sh"
      puts "#{:server} reports: #{myTask}"
    end
  end
  1. Is this correct?
  2. Is the ssh part of the whole process or I have to ssh in the command?
  3. How do people develope deploy.rb without cap deploy every time they make a change?

Thank you!

aerijman
  • 2,522
  • 1
  • 22
  • 32

2 Answers2

0

Ruby allows you to run a shell script using backtick

for example

output = `pwd`
puts "output is #{output}"

see more https://ruby-doc.org/core-1.9.3/Kernel.html#method-i-60

Rafaiel
  • 302
  • 4
  • 12
0

This is what worked for me:

role :app, 'user@domain1.com'

on roles(:app) do
  within 'remote_path' do
    execute 'bash', ' myScript.sh'
  end
end
aerijman
  • 2,522
  • 1
  • 22
  • 32