<commit_before># Fezzik

Fezzik (or fez) is a slim and snappy way to run commands on servers.
This is useful for many tasks, including deployment.

It wraps a rake-based rsync workflow and tries to keep things simple.

If upgrading to 0.8 from an earlier version of Fezzik, see [Upgrading](#upgrading).

## Install

```
gem install fezzik
```

## Basic setup

Require Fezzik in your project Rakefile and define a destination:

```ruby
require "fezzik"

Fezzik.destination :prod do
  Fezzik.set :user, "root"
  Fezzik.set :domain, "myapp.com"
end
```

A host task is similar to a normal Rake task, but will run once for every host defined by `:domain`. The body
of a host task exposes two methods:

```
run <command> Run a shell command on the remote host
host          The domain that the currently running host task is targeting
```

Write some host tasks that will execute on the specified destination:

```ruby
namespace :fezzik do
  Fezzik.host_task :echo do
    run "echo 'Running on #{host}'"
  end
end
```

Run your host tasks with fezzik by passing a destination and list of tasks to run:

```
$ fez prod echo
```

### host_task

The `host_task` method is similar to Rake's `task` in functionality, but has a slightly different API due to
its additional options. A host task is defined with a name and three (optional) options: `:args`, `:deps`,
and `:roles`. `:args` and `:deps` correspond to Rake's task arguments and task dependencies, and `:roles` is a
Fezzik-specific option explained later.

A Rake task that looks like this:

```ruby
task :echo, [:arg1, :arg2] => [:dep1, :dep2] do |t, args|
  ...
end
```

would look like this as a host task:

```ruby
Fezzik.host_task :echo, :args => [:arg1, :arg2],
                        :deps => [:dep1, :dep2] do |t, args|
  ...
end
```


## Deployments

One of the more useful things you can use Fezzik for is handling deployments.

```ruby
require "fezzik"

# Fezzik will automatically load any .rake files it finds in this directory.
Fezzik.init(:tasks => "config/tasks")

# The only special settings are `:domain` and `:user`. The rest are purely convention. All settings can be
# retrieved in your tasks with `get` (e.g., `Fezzik.get :current_path`).
Fezzik.set :app, "myapp"
Fezzik.set :user, "root"
Fezzik.set :deploy_to, "/opt/#{app}"
Fezzik.set :release_path, "#{deploy_to}/releases/#{Time.now.strftime("%Y%m%d%H%M")}"
Fezzik.set :current_path, "#{deploy_to}/current"

Fezzik.destination :staging do<commit_msg>Fix deprecated syntax in README<commit_after># Fezzik

Fezzik (or fez) is a slim and snappy way to run commands on servers.
This is useful for many tasks, including deployment.

It wraps a rake-based rsync workflow and tries to keep things simple.

If upgrading to 0.8 from an earlier version of Fezzik, see [Upgrading](#upgrading).

## Install

```
gem install fezzik
```

## Basic setup

Require Fezzik in your project Rakefile and define a destination:

```ruby
require "fezzik"

Fezzik.destination :prod do
  Fezzik.set :user, "root"
  Fezzik.set :domain, "myapp.com"
end
```

A host task is similar to a normal Rake task, but will run once for every host defined by `:domain`. The body
of a host task exposes two methods:

```
run <command> Run a shell command on the remote host
host          The domain that the currently running host task is targeting
```

Write some host tasks that will execute on the specified destination:

```ruby
namespace :fezzik do
  Fezzik.host_task :echo do
    run "echo 'Running on #{host}'"
  end
end
```

Run your host tasks with fezzik by passing a destination and list of tasks to run:

```
$ fez prod echo
```

### host_task

The `host_task` method is similar to Rake's `task` in functionality, but has a slightly different API due to
its additional options. A host task is defined with a name and three (optional) options: `:args`, `:deps`,
and `:roles`. `:args` and `:deps` correspond to Rake's task arguments and task dependencies, and `:roles` is a
Fezzik-specific option explained later.

A Rake task that looks like this:

```ruby
task :echo, [:arg1, :arg2] => [:dep1, :dep2] do |t, args|
  ...
end
```

would look like this as a host task:

```ruby
Fezzik.host_task :echo, :args => [:arg1, :arg2],
                        :deps => [:dep1, :dep2] do |t, args|
  ...
end
```


## Deployments

One of the more useful things you can use Fezzik for is handling deployments.

```ruby
require "fezzik"

# Fezzik will automatically load any .rake files it finds in this directory.
Fezzik.init(:tasks => "config/tasks")

# The only special settings are `:domain` and `:user`. The rest are purely convention. All settings can be
# retrieved in your tasks with `get` (e.g., `Fezzik.get :current_path`).
Fezzik.set :app, "myapp"
Fezzik.set :user, "root"
Fezzik.set :deploy_to, "/opt/#{Fezzik.get :app}"
Fezzik.set :release_path, "#{Fezzik.get :deploy_to}/releases/#{Time.now.strftime("%Y%m%d%H%M")}"
Fezzik.set :current_path, "#{Fezzik.get :deploy_to}/current"

Fezzik.destination :staging do
{'fraction_non_alphanumeric': 0.11510791366906475, 'fraction_numerical': 0.003996802557953637, 'mean_word_length': 4.05045408678103, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '36102', 'n_tokens_mistral': 1736, 'n_tokens_neox': 1627, 'n_words': 692}