The file deploy.rb
is simply a Rakefile invoked by Rake. In fact, mina
is
mostly an alias that invokes Rake to load deploy.rb
.
## Sample config/deploy.rb
set :domain, 'your.server.com'
task :restart do
comment 'Restart application'
command "passenger-config restart-app --ignore-app-not-running #{deploy_to}"
end
As it’s all Rake, you can define tasks that you can invoke using mina
. In this
example, it provides the mina restart
command.
The magic of Mina is in the new commands it gives you.
The command
command queues up Bash commands to be run on the remote server.
If you invoke mina restart
, it will invoke the task above and run the queued
commands on the remote server your.server.com
via SSH.
Invokes another Rake task.
invoke :'git:clone'
invoke :restart
Adds a command to the command queue.
This queues code to be run on the current queue name (defaults to :default
).
By default, whitespace is stripped from the beginning and end of the command.
command %{ls -al} # => [ls -al]
Adds a comment to the command queue.
comment %{ls -al} # => [echo "-----> ls -al"]
Runs the given block on the defined backend (remote or local)
run :remote do
command %{ls -al}
end
Change the queue name for the given block. Use this if you have multiple places where commands need to end up. Mainly used in deploy
task.
on :launch do
invoke :restart
end
Change the path the commands in the given block is run.
in_path('some/new/path') do
command %{ls -al} # => cd some/new/path && ls -al
end
Sets configuration variable. Can a value or a proc/lambda.
set :deploy_to -> '/path/to/deploy'
Gets configuration variable. Runs .call
if callable.
Returns nil if not set. If default parameter is passed returns default if not set.
fetch(:deploy_to)
fetch(:deploy_to, 'some_default')
Checks if a variable is set.
set?(:deploy_to)
Raises an error if variable is not set
ensure!(:deploy_to)