Whenever changing the cron in staging environments.

1,543 views
Skip to first unread message

Tim Uckun

unread,
Jan 1, 2013, 6:43:38 PM1/1/13
to whenev...@googlegroups.com
Is there a way to prevent whenever from altering cron unless the
environment is production? Every time I push it to staging it changes
the cron task.

Thanks.

jam...@gmail.com

unread,
Feb 11, 2013, 3:35:31 PM2/11/13
to whenev...@googlegroups.com
I would like to know this as well. For example we don't want the cron to update on our staging box AT ALL, and we do want it to correctly deploy on production. Any assistance with how to do a conditional deploy or no-deploy based on stage given in the cap file would be great.

Javan Makhmali

unread,
Feb 11, 2013, 11:23:07 PM2/11/13
to whenev...@googlegroups.com
If you're using Cap multistage, you could just require whenever/capistrano in your deploy/production.rb file and leave it out of your other environments.

-Javan


--
--
You received this message because you are subscribed to the Google
Groups "Whenever Gem" group and because you're awesome.
To post to this group, send email to whenev...@googlegroups.com
To unsubscribe from this group, send email to
whenever-gem...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/whenever-gem?hl=en
---
You received this message because you are subscribed to the Google Groups "Whenever Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email to whenever-gem...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Tim Uckun

unread,
Feb 12, 2013, 6:58:02 AM2/12/13
to whenev...@googlegroups.com
On Tue, Feb 12, 2013 at 5:23 PM, Javan Makhmali <ja...@javan.us> wrote:
> If you're using Cap multistage, you could just require whenever/capistrano
> in your deploy/production.rb file and leave it out of your other
> environments.


In my case I only needed my jobs to run in one env so I took this
approach. This solution would not work for somebody who wants to run
different jobs in different environments though.

karthik...@gmail.com

unread,
Jan 30, 2014, 1:24:10 AM1/30/14
to whenev...@googlegroups.com
Exactly tim, like me

I need to run all tasks in both environments, except for a couple which run in only production. Would be nice if whenever supported rails/capistrano style env files ("whenever/staging.rb") or the roles like filtering (environment:  [:production] )

Wonder if I can simulate the former with some require.. let me try.

karthik...@gmail.com

unread,
Jan 30, 2014, 2:10:22 AM1/30/14
to whenev...@googlegroups.com, karthik...@gmail.com
Its not pretty but i got it working finally..
Require/require relative/load was failing on me, probably cuz eval was being used..

So I copied a line from the source, placed the below line in my schedule.rb
instance_eval(File.read("./config/whenever/#{environment}.rb"), options[:file] || '<eval>')

and made a folder structure like this

config
    schedule.rb
    whenever
        production.rb
        staging.rb

(This is for rails, but should be possible to repurpose for other situations.)

Tim Uckun

unread,
Jan 30, 2014, 3:53:43 PM1/30/14
to whenev...@googlegroups.com, karthik...@gmail.com
Nice idea.




--

tho...@sijn.org

unread,
Mar 5, 2014, 11:11:54 AM3/5/14
to whenev...@googlegroups.com, karthik...@gmail.com
Does this work for capistrano 3? because i can't figure out how to set the multistage for cap 3?

Op donderdag 30 januari 2014 21:53:43 UTC+1 schreef tim:

Karthik T

unread,
Mar 5, 2014, 8:11:03 PM3/5/14
to tho...@sijn.org, whenev...@googlegroups.com
I havent really used Capistrano 3 before (using 2.x now), but it should work with minor modification i guess..

Javan Makhmali

unread,
Mar 6, 2014, 8:05:44 AM3/6/14
to whenev...@googlegroups.com
I added some alternative options here: https://github.com/javan/whenever/pull/421#issuecomment-36459996

-Javan
Reply all
Reply to author
Forward
0 new messages