Multiple Capistrano 3 questions

27 views
Skip to first unread message

José Sá

unread,
Sep 11, 2015, 3:00:19 PM9/11/15
to Capistrano
Hi all,


i'm trying to create a custom deploy script but having some trouble in some aspects:

1. I want to deploy the servers with role DB before starting to run other servers. So:
 Start deploy
 - Run deploy sequence in the the servers with the specific role,
 - When finished start the other servers

This scenario doesn't seem to be covered natively.

2. I need to perform some complex file manipulation on the remote server as part of the deployment process.
Currently I have a bash script that does this but I would prefer to have the whole deployment script inside Capistrano rules instead of calling external scripts.

I can convert it into ruby (is mostly reading a bunch of files and use sed to generate a new one), so I would like to know the best practise here.

Call invoke with a multiline script?


Lee Hambley

unread,
Sep 11, 2015, 3:13:38 PM9/11/15
to Capistrano
Hi Jose,

It's not clear from your post whether you're loading the `rails/all` (or maybe just `rails/migrations`, but I'll answer under the assumption that you're not, and that if you are, whatever they do to your database servers (run migrations) is not a problem.

Assuming that you can convert your script to Ruby, or run it still via Bash, probably Ruby would be more robust, anyway, http://www.shellcheck.net/ is a decent tool to run your Bash script through, if sticking with Bash. Both will work.

task :fixitup do
on roles(:db) do |host|
 upload! './my-local-script.rb', './my-script.rb'
 execute :ruby, "./my-script.rb"
end
end

after "deploy:starting", "fixitup"

--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/a3272533-6f1f-4386-9aa2-f858bf376bec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

José Sá

unread,
Sep 13, 2015, 10:09:03 AM9/13/15
to Capistrano
Hummm I see,

I was hoping to precisely get rid of helper scripts in order to deploy. I was hoping to be able to write a few helper methods in ruby that could be run directly in the remote host. But I guess that is limited with "oneliner" shell commands.

José

Lee Hambley

unread,
Sep 13, 2015, 11:51:24 AM9/13/15
to Capistrano

Capistrano runs locally, you can script commands to replace your script, or upload it.

Reply all
Reply to author
Forward
0 new messages