Skip to content
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

Add environment command-line arg to whenever crontab write; update re… #64

Merged
Merged
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
9 changes: 8 additions & 1 deletion rails/tasks/whenever/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ Updates Crontab of ``app_user`` with crontab. Requires Gem ``whenever`` to be pr

### Usage:


```yaml
roles:
# ...
- role: dresden-weekly.Rails/rails/tasks/whenever
```

- If using in any environment other than `production`, be sure to include the `@environment` argument (which comes in via `--set environment={{ rails_env}}` in the task) in your `config/schedule.rb` file, like this:

```
every 1.day, at: "4:00am" do
rake "some_task:thing", environment: @environment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would guess that rake tasks pick up the @environment without this parameter.

end
```
2 changes: 1 addition & 1 deletion rails/tasks/whenever/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: Update cronjobs for app
command: "{{ profile }}'bundle exec whenever --update-crontab {{ app_name }}'"
command: "{{ profile }}'bundle exec whenever --set environment={{ rails_env}} --update-crontab {{ app_name }}'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--set environment=$RAILS_ENV should work here.

We never use the rails_env argument in the Rails roles. So it would be undocumented.

args:
chdir: "{{ RAILS_APP_RELEASE_PATH }}"
register: rails_whenever_result