Capistrano roles and multiple app server environment

155 views
Skip to first unread message

Nathan Ladd

unread,
Jan 17, 2012, 11:52:11 AM1/17/12
to Whenever Gem
I've done some googling and haven't found a solution for my problem
yet. Apologies in advance if this problem has been solved and my
inadequate google-fu was unable to find the solution.

What I'm trying to accomplish is this: I've got two app servers. I'd
like to assign one of those app servers then :cron role, and run
*almost all* of my cronjobs on that server. Which is simple enough to
do, I just go into my whenever configuration in config/deploy.rb and
tell capistrano to only invoke whenever on that particular role.

But unfortunately I have two cron jobs that I want to run on *every*
server -- I need to rebuild my fulltext search index, for one. I also
have a cron job that I only want to run on my database server.

So, is there a way to tell capistrano to run whenever on *all* the
servers that run *at least one* cronjob, and then in my config/
schedule.rb to define cronjobs that are restricted to particular
roles, e.g.

if Whenever.role == :cron
every 1.day do
bill my clients/etc.
end
elsif Whenever.role == :db
every 1.day do
backup the database
end
elsif Whenever.role == :app
every 1.day do
rebuild my fulltext search index
end
end

Reply all
Reply to author
Forward
0 new messages