Skip to content

Commit

Permalink
Merge pull request #49 from cmckni3/fix-rufus-initializer
Browse files Browse the repository at this point in the history
Don't rescue generic exception. This will hang the process
  • Loading branch information
owen2345 committed Sep 3, 2015
2 parents 28ab66b + f5fd437 commit 89cdf6f
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions config/initializers/rufus_cron.rb
Expand Up @@ -6,29 +6,24 @@
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License (GPLv3) for more details.
=end
require 'rufus-scheduler'
$scheduler = Rufus::Scheduler.singleton
$scheduler.cron '00 05 * * *' do
system("rake camaleon_cms:sitemap")
end
# cronjob for hook by site
begin
require 'rufus-scheduler'
$scheduler = Rufus::Scheduler.singleton
$scheduler.cron '00 05 * * *' do
system("rake camaleon_cms:sitemap")
end
#cronjob for hook by site
begin
Site.all.each do |site|
# hooks
c = CamaleonController.new
c.instance_eval do
@current_site = site
@_hooks_skip = []
end
r = {site: site, eval: nil}; c.hooks_run("cron", r)
r[:eval].call(r) if r[:eval].present?
Site.all.each do |site|
# hooks
c = CamaleonController.new
c.instance_eval do
@current_site = site
@_hooks_skip = []
end
rescue => e # skipping sites not found

r = {site: site, eval: nil}; c.hooks_run("cron", r)
r[:eval].call(r) if r[:eval].present?
end
rescue LoadError

rescue ActiveRecord::RecordNotFound # skipping sites not found
end

# only for camaleon site
Expand All @@ -51,4 +46,4 @@ def perform(file_path)
FileUtils.rm_rf(file_path) if File.exist?(file_path) && !File.directory?(file_path)
end
end
end
end

0 comments on commit 89cdf6f

Please sign in to comment.