Skip to content

Namespace environment by default and cleaning capistrano integration section #817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,23 @@ every 3.hours do
end
```

### Capistrano integration
### Capistrano Integration

In your `Capfile` file:

```ruby
require "whenever/capistrano"
```

Take a look at the [load:defaults task](https://github.com/javan/whenever/blob/master/lib/whenever/capistrano/v3/tasks/whenever.rake) (bottom of file) for options you can set.

The Capistrano integration by default expects the `:application` variable to be set in order to scope jobs in the crontab.

### Capistrano V2 integration

Use the built-in Capistrano recipe for easy crontab updates with deploys. For Capistrano V3, see the next section.

In your "config/deploy.rb" file:
In your `config/deploy.rb` file:

```ruby
require "whenever/capistrano"
Expand Down Expand Up @@ -222,22 +234,6 @@ set :whenever_load_file, defer { "#{release_path}/somewhere/else/schedule.rb" }
require "whenever/capistrano"
```

### Capistrano V3 Integration

In your "Capfile" file:

```ruby
require "whenever/capistrano"
```

Take a look at the [load:defaults task](https://github.com/javan/whenever/blob/master/lib/whenever/capistrano/v3/tasks/whenever.rake) (bottom of file) for options you can set. For example, to namespace the crontab entries by application and stage do this in your "config/deploy.rb" file:

```ruby
set :whenever_identifier, ->{ "#{fetch(:application)}_#{fetch(:stage)}" }
```

The Capistrano integration by default expects the `:application` variable to be set in order to scope jobs in the crontab.

### Capistrano roles

The first thing to know about the new roles support is that it is entirely
Expand Down
4 changes: 2 additions & 2 deletions lib/whenever/capistrano/v3/tasks/whenever.rake
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ namespace :load do
set :whenever_roles, ->{ :db }
set :whenever_command, ->{ [:bundle, :exec, :whenever] }
set :whenever_command_environment_variables, ->{ fetch(:default_env).merge(rails_env: fetch(:whenever_environment)) }
set :whenever_identifier, ->{ fetch :application }
set :whenever_environment, ->{ fetch :rails_env, fetch(:stage, "production") }
set :whenever_identifier, ->{ "#{fetch(:application)}_#{fetch(:whenever_environment)}" }
set :whenever_environment, ->{ fetch(:rails_env, fetch(:stage, "production")) }
set :whenever_variables, ->{ "environment=#{fetch :whenever_environment}" }
set :whenever_load_file, ->{ nil }
set :whenever_update_flags, ->{ "--update-crontab #{fetch :whenever_identifier} --set #{fetch :whenever_variables}" }
Expand Down