[noosfero/noosfero][master] 2 commits: delayed_job: port exception notifications to rails 3

Leandro Nunes leandronunes at gmail.com
Tue Jun 2 21:00:11 BRT 2015


Braulio we can't make rake db:migrate or db:schema:load anymore because of
this.

Please it's really annoying take the master branch broke everytime.

-------------------------

user at serpro-1552757:~/projetos/noosfero$ rake db:migrate
rake aborted!
LoadError: cannot infer basepath
/home/user/projetos/noosfero/vendor/plugins/monkey_patches/init.rb:1:in
`require_relative'
/home/user/projetos/noosfero/vendor/plugins/monkey_patches/init.rb:1:in
`block in <class:Plugin>'
-------------------------

Please.

Fix the unit tests falling related to enterprises too.

w


On Tue, Jun 2, 2015 at 3:37 PM, Bráulio Bhavamitra <gitlab at gitlab.com>
wrote:

>  Bráulio Bhavamitra pushed to branch master at Noosfero / noosfero
> <https://gitlab.com/noosfero/noosfero> Commits:
>
>    - *c9a234ca
>    <https://gitlab.com/noosfero/noosfero/commit/c9a234cad88608cadc7388aab7eb4f553bd67a2d>*
>    by Braulio Bhavamitra *at 2015-05-20T21:13:02Z*
>
>    delayed_job: port exception notifications to rails 3
>
>     - *c51caedd
>    <https://gitlab.com/noosfero/noosfero/commit/c51caedd718da2f1edafee0e075ca1cbeb776b2b>*
>    by Bráulio Bhavamitra *at 2015-06-02T18:37:09Z*
>
>    Merge branch 'delayed-job-exception-notification' into 'master'
>
>    delayed_job: port exception notifications to rails 3
>
>    See merge request !580
>
>
> 4 changed files:
>
>    -  config/initializers/delayed_job_config.rb <#14db59078f28c022_diff-0>
>    -  vendor/plugins/delayed_job/lib/delayed/backend/base.rb
>    <#14db59078f28c022_diff-1>
>    -  vendor/plugins/monkey_patches/init.rb <#14db59078f28c022_diff-2>
>    -  − vendor/plugins/monkey_patches/rescue_delayed_job_crashes/init.rb
>    <#14db59078f28c022_diff-3>
>
> Changes:
>  * config/initializers/delayed_job_config.rb *
> <https://gitlab.com/noosfero/noosfero/compare/0bf5c21e5e02a4538df5033513072676d6c953c6...c51caedd718da2f1edafee0e075ca1cbeb776b2b#diff-0>
> ------------------------------
>
> --- a/config/initializers/delayed_job_config.rb+++ b/config/initializers/delayed_job_config.rb@@ -23,3 +23,13 @@ end #  end
>  #  alias_method_chain :handle_failed_job, :loggin
>  #end+
> +# Chain delayed job's handle_failed_job method to do exception notification
> +Delayed::Worker.class_eval do
> +  def handle_failed_job_with_notification job, error
> +    handle_failed_job_without_notification job, error
> +    ExceptionNotifier.notify_exception error, exception_recipients: NOOSFERO_CONF['exception_recipients'],
> +      data: {job: job, handler: job.handler} rescue nil
> +  end
> +  alias_method_chain :handle_failed_job, :notification
> +end
>
>
>   * vendor/plugins/delayed_job/lib/delayed/backend/base.rb *
> <https://gitlab.com/noosfero/noosfero/compare/0bf5c21e5e02a4538df5033513072676d6c953c6...c51caedd718da2f1edafee0e075ca1cbeb776b2b#diff-1>
> ------------------------------
>
> --- a/vendor/plugins/delayed_job/lib/delayed/backend/base.rb+++ b/vendor/plugins/delayed_job/lib/delayed/backend/base.rb@@ -73,9 +73,8 @@ module Delayed       ParseObjectFromYaml = /\!ruby\/\w+\:([^\s]+)/
>
>        def name-        @name ||= payload_object.respond_to?(:display_name) ?
> -                    payload_object.display_name :
> -                    payload_object.class.name+        obj = payload_object
> +        @name ||= obj.respond_to?(:display_name) ? obj.display_name : obj.class.name       rescue DeserializationError
>          ParseObjectFromYaml.match(handler)[1]
>        end
>
>
>   * vendor/plugins/monkey_patches/init.rb *
> <https://gitlab.com/noosfero/noosfero/compare/0bf5c21e5e02a4538df5033513072676d6c953c6...c51caedd718da2f1edafee0e075ca1cbeb776b2b#diff-2>
> ------------------------------
>
> --- a/vendor/plugins/monkey_patches/init.rb+++ b/vendor/plugins/monkey_patches/init.rb@@ -1,3 +1,3 @@-require File.join(File.dirname(__FILE__), 'attachment_fu_validates_attachment/init')
> -require File.join(File.dirname(__FILE__), 'attachment_fu/init')
> -require File.join(File.dirname(__FILE__), 'white_list_sanitizer_unescape_before_reescape/init')+require_relative 'attachment_fu_validates_attachment/init'
> +require_relative 'attachment_fu/init'
> +require_relative 'white_list_sanitizer_unescape_before_reescape/init'
>
>
>   * vendor/plugins/monkey_patches/rescue_delayed_job_crashes/init.rb *
> deleted
> <https://gitlab.com/noosfero/noosfero/compare/0bf5c21e5e02a4538df5033513072676d6c953c6...c51caedd718da2f1edafee0e075ca1cbeb776b2b#diff-3>
> ------------------------------
>
> --- a/vendor/plugins/monkey_patches/rescue_delayed_job_crashes/init.rb+++ /dev/null@@ -1,57 +0,0 @@-Delayed::Worker.module_eval do-  # based on https://groups.google.com/forum/#!topic/delayed_job/ZGMUFFppNgs
> -  class Delayed::Worker::ExceptionNotification < ActionMailer::Base
> -    def mail job, error
> -      environment = Environment.default--      recipients NOOSFERO_CONF['exception_recipients']
> -      from       environment.noreply_email
> -      reply_to   environment.noreply_email
> -      subject    "[#{environment.name}] DelayedJob ##{job.id}: #{error.message}"
> -      body       render(:text => "-Job:
> -#{job.inspect}
> -
> -Handler:
> -#{job.handler}
> -
> -Backtrace:
> -#{error.backtrace.join("\n")}-      ")
> -    end
> -  end--  def handle_failed_job_with_notification(job, error)
> -    Delayed::Worker::ExceptionNotification.deliver_mail job, error if NOOSFERO_CONF['exception_recipients'].present?
> -    handle_failed_job_without_notification job, error
> -  end
> -  alias_method_chain :handle_failed_job, :notification--  def handle_failed_job_with_rescue(job, error)
> -    handle_failed_job_without_rescue(job, error)
> -  rescue => e # don't crash here
> -  end
> -  alias_method_chain :handle_failed_job, :rescue--  protected--  # This code must be replicated because there is no other way to pass the job
> -  # through and use alias_method_chain as we used on the previous method
> -  def reserve_and_run_one_job
> -    # We get up to 5 jobs from the db. In case we cannot get exclusive access to a job we try the next.
> -    # this leads to a more even distribution of jobs across the worker processes
> -    job = Delayed::Job.find_available(name, 5, self.class.max_run_time).detect do |job|
> -      if job.lock_exclusively!(self.class.max_run_time, name)
> -        say "acquired lock on #{job.name}"
> -        true
> -      else
> -        say "failed to acquire exclusive lock for #{job.name}", Logger::WARN
> -        false
> -      end
> -    end--    run(job) if job
> -  rescue => e
> -    handle_failed_job(job, e)
> -  end-end
>
>
>> View it on GitLab
> <https://gitlab.com/noosfero/noosfero/compare/0bf5c21e5e02a4538df5033513072676d6c953c6...c51caedd718da2f1edafee0e075ca1cbeb776b2b>
>
> _______________________________________________
> Noosfero-dev mailing list
> Noosfero-dev at listas.softwarelivre.org
> http://listas.softwarelivre.org/cgi-bin/mailman/listinfo/noosfero-dev
>
>


-- 
Dois Axé!!!

-----
"Comece fazendo o que é necessário, depois o que é possível e de repente
você estará fazendo o impossível."
                                   São Francisco de Assis
Leandro Nunes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150602/e21bb6cc/attachment.html>


More information about the Noosfero-dev mailing list