No commit activity in last 3 years
No release in over 3 years
Mina multi-server support
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.0
 Project Readme

Mina Multi Server

This is an extremely simple gem that adds multi-server support to Mina tasks. In order to avoid complexity, each task is executed sequentially. You should look at other solutions if you need parallel execution.

Installation

gem install mina-multi_server

Usage

When using mina-multi_server, there is no need to set a domain var as Mina requires, just set a servers array in your deploy.rb with the hostnames of the servers where you want the tasks to be executed on.

# deploy.rb

require 'mina/multi_server'

set :servers, ['server-1.example.com', 'server-2.example.com']

# ...
$ mina deploy

How it works

Each remote task will be executed for each server of servers array, setting ENV['domain'] to each server. Mina checks ENV[domain] when fetching the domain to be used by the task. Using the ENV keeps the domain var of Mina untouched, so you can still use it for other task (such as ssh). In addition, ENV['domain'] is also restored to its previous value in case it was set.

For non-remote tasks, each task will be executed only once and servers var will not be used.

Tasks will be executed one after the other, sequentially.

Running tasks on a single server

Mina-multi_server includes a select task that lets you pick the server where you want the task to be executed on. You just need to call it before the main task. You will also need to require mina/multi_server/select in your deploy.rb.

# deploy.rb

require 'mina/multi_server'
require 'mina/multi_server/select'

set :servers, ['server-1.example.com', 'server-2.example.com']

# ...
$ mina select ssh

Select server:
1. server-1.example.com
2. server-2.example.com
>

After you select an option, the domain var that Mina uses will be set to the selected server. In addition, the servers array will be reduced to a single-item array including only the selected server.

Multi-stage (production, staging)

Multistage deploys can be achieved using a task for setting the servers array before executing the main task.

# deploy.rb

require 'mina/multi_server'

task :production
  set :servers, ['server-1.example.com', 'server-2.example.com']
end

task :staging
  set :servers, ['staging.example.com']
end

# ...
$ mina production deploy

This will deploy to server-1.example.com and server-2.example.com.

$ mina staging deploy

This will deploy only to staging.example.com.