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

Whenever taking 'production' environment during local development. #660

Closed
prasadsurase opened this issue Sep 9, 2016 · 7 comments · Fixed by #832
Closed

Whenever taking 'production' environment during local development. #660

prasadsurase opened this issue Sep 9, 2016 · 7 comments · Fixed by #832

Comments

@prasadsurase
Copy link

I am using whenever(0.9.7) with rails(4.2.5.2) and ruby(2.3.0). Whenever I update the crontab using whenever, the RAILS_ENV is set to production which actually should be development since my application is running in the development env. Is this a bug or an expected behaviour?

$ crontab -l
crontab: no crontab for prasad
$ whenever --update-crontab
$ crontab -l
# Begin Whenever generated tasks for: /Users/prasad/myproject/config/schedule.rb
0 0 * * * /bin/bash -l -c 'cd /Users/prasad/myproject && RAILS_ENV=production bundle exec rake fetch_data:get_some_data --silent >> /home/deploy/projects/myproject/current/cron_log.log 2>&1'

$ crontab -r
$ crontab -l
crontab: no crontab for prasad
$ whenever --update-crontab --set environment=development
[write] crontab file updated
$ crontab -l
# Begin Whenever generated tasks for: /Users/prasad/myproject/config/schedule.rb
0 0 * * * /bin/bash -l -c 'cd /Users/prasad/myproject && RAILS_ENV=development bundle exec rake fetch_data:get_some_data --silent >> /home/deploy/projects/myproject/current/cron_log.log 2>&1'
@benlangfeld
Copy link
Collaborator

Your pasted logs show this working. What's the problem?

@vcavallo
Copy link

vcavallo commented Feb 2, 2017

It looks like the issue @prasadsurase is bringing up is that without explicitly passing in --set environment=development, the environment defaults to production. I realize that's the documented behavior, but if I'm understanding correctly, @prasadsurase thinks whenever should use development when "in development" (similar to how rails s works by default).

@unikitty37
Copy link

This is documented in the "Setting variables on the fly" page of the wiki, but not in the README — which is otherwise sufficiently comprehensive that most people wouldn't even think to check the wiki. Could it be added?

I'd agree that matching the RAILS_ENV the "whenever" command is running in should be the default, though, rather than always defaulting to "production". Convention over configuration, and all that.

(as an aside, there's a page called "instruction and examples" in the wiki which just consists of "bbbbb" :)

@benlangfeld
Copy link
Collaborator

@unikitty37 I would accept a PR which includes all wiki content into the README. If you would be willing to prep that, I would appreciate it. I can then deactivate the wiki entirely.

@benlangfeld
Copy link
Collaborator

I'd also accept a PR which defaults to matching RAILS_ENV if anyone has time / inclination to prep that.

Haegin added a commit to relayplatform/whenever that referenced this issue Feb 13, 2020
Fixes javan#660

This changes whenever to get set the environment for cron jobs based off
the currently set RAILS_ENV environment variable. If RAILS_ENV is not
set it defaults to production to be backwards compatible with the
previous behaviour.
@ziaulrehman40
Copy link

i see an open pr

@jeremiahlukus
Copy link

@benlangfeld

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants