exception_notification 配置

[b]安装 super_exception_notifier[/b]
gem 方式1:
       sudo gem sources -a http://gemcutter.org 
gem install super_exception_notifier


gem 方式2:
  mkdir -p ~/src
cd ~/src
git clone git://github.com/pboling/exception_notification.git
cd exception_notification
gem build exception_notification.gemspec
sudo gem install super_exception_notification-2.0.0.gem # (Or whatever version gets built)



plugin git 方式:
  ./script/plugin install git://github.com/pboling/exception_notification.git


plugin svn 方式:
   ./script/plugin install http://super-exception-notifier.googlecode.com/svn/trunk/super_exception_notifier



[b]application controller 中加入[/b]


class ApplicationController < ActionController::Base
include ExceptionNotifiable
...
end


[b]配置exception_notifier[/b]
添加文件 exception_notifier.rb 到 config/initializers/exception_notifier.rb
exception_notifier.rb :
ExceptionNotifier.configure_exception_notifier do |config|
# If left empty web hooks will not be engaged
config[:web_hooks] = []
config[:app_name] = "[Project Name]"
# NOTE: THERE IS A BUG IN RAILS 2.3.3 which forces us to NOT use anything but a simple email address string for the sender address.
# https://rails.lighthouseapp.com/projects/8994/tickets/2340
# config[:sender_address] = %("#{(defined?(Rails) ? Rails.env : RAILS_ENV).capitalize} Error" <super.exception.notifier@example.com>)
config[:sender_address] = %("Project Name" <project_name.error@mail.project_name.com>)
config[:exception_recipients] = %w(project_name@googlegroups.com)
# Customize the subject line
#config[:subject_prepend] = "[#{(defined?(Rails) ? Rails.env : RAILS_ENV).capitalize} ERROR] "
config[:subject_prepend] = "[ProjectName ERROR] "
config[:subject_append] = " :("
# Include which sections of the exception email?
config[:sections] = %w(request session environment backtrace)
# Only use this gem to render, never email
#defaults to false - meaning by default it sends email. Setting true will cause it to only render the error pages, and NOT email.
config[:skip_local_notification] = true
# Example:
#config[:view_path] = 'app/views/error'
config[:view_path] = nil
# Error Notification will be sent if the HTTP response code for the error matches one of the following error codes
config[:notify_error_codes] = %W( 405 500 503 )
# Error Notification will be sent if the error class matches one of the following error error classes
config[:notify_error_classes] = %W( )
# What should we do for errors not listed?
config[:notify_other_errors] = true
# If you set this SEN will
config[:git_repo_path] = nil
config[:template_root] = "#{File.dirname(__FILE__)}/../views"
end



[b]配置ActionMailer[/b]

可以加一个配置文件 config/config.yml


public:
smtp_server: 'mail.xxxx.com'
smtp_port: 25
smtp_domain: 'www.xxxx.com'
smtp_user_name: 'info@xxxx.com'
smtp_passwd: ""
smtp_authentication: 'login'
test:
smtp_server: 'mail.xxxx.com'
smtp_port: 25
smtp_domain: 'www.xxxx.com'
smtp_user_name: 'info@xxxx.com'
smtp_passwd: ""
smtp_authentication: 'login'
development:
smtp_server: 'mail.xxxx.com'
smtp_port: 25
smtp_domain: 'mail.xxxx.com'
smtp_user_name: 'info@xxxx.com'
smtp_passwd: ""
smtp_authentication: 'login'
production:
smtp_server: 'mail.xxxx.com'
smtp_port: 25
smtp_domain: 'mail.xxxx.com'
smtp_user_name: ''
smtp_passwd: ''
smtp_authentication: ''



[b]加文件 20_mailer_config.rb[/b]

PUBLIC_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml")['public']
PRIVATE_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml")[RAILS_ENV]
CONFIG = PUBLIC_CONFIG.merge(PRIVATE_CONFIG || Hash.new)

ActionMailer::Base.smtp_settings = {
:address => CONFIG['smtp_server'],
:port => CONFIG['smtp_port'],
:domain => CONFIG['smtp_domain'],
:user_name => (CONFIG['smtp_authentication'].blank? ? nil : CONFIG['smtp_user_name']),
:password => (CONFIG['smtp_authentication'].blank? ? nil : CONFIG['smtp_passwd']),
:authentication => (CONFIG['smtp_authentication'].blank? ? nil : CONFIG['smtp_authentication'])
}

ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true



[b]如果gem方式要加入gem 引用到 config/environment.rb[/b]

    config.gem 'super_exception_notifier', :version => '~> 2.0.0', :lib => "exception_notifier"



[b]如果要在本地测试要作下面三件事情:[/b]
1.服务要以production模式启动
2.config/initializers/exception_notifier.rb 中 config[:skip_local_notification] = false
3.在application controller 加 local_addresses.clear
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Stdoutput Warning: /opt/cloudera/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554/bin/../lib/sqoop/../accumulo does not exist! Accumulo imports will fail. Stdoutput Please set $ACCUMULO_HOME to the root of your Accumulo installation. Exit code of the Shell command 1 <<< Invocation of Shell command completed <<< java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.oozie.action.hadoop.LauncherAM.runActionMain(LauncherAM.java:410) at org.apache.oozie.action.hadoop.LauncherAM.access$300(LauncherAM.java:55) at org.apache.oozie.action.hadoop.LauncherAM$2.run(LauncherAM.java:223) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1875) at org.apache.oozie.action.hadoop.LauncherAM.run(LauncherAM.java:217) at org.apache.oozie.action.hadoop.LauncherAM$1.run(LauncherAM.java:153) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1875) at org.apache.oozie.action.hadoop.LauncherAM.main(LauncherAM.java:141) Caused by: org.apache.oozie.action.hadoop.LauncherMainException at org.apache.oozie.action.hadoop.ShellMain.run(ShellMain.java:76) at org.apache.oozie.action.hadoop.LauncherMain.run(LauncherMain.java:104) at org.apache.oozie.action.hadoop.ShellMain.main(ShellMain.java:63) ... 16 more Failing Oozie Launcher, Main Class [org.apache.oozie.action.hadoop.ShellMain], exit code [1] Oozie Launcher, uploading action data to HDFS sequence file: hdfs://nameservice0/user/admin/oozie-oozi/0000118-230724100647793-oozie-oozi-W/shell-af10--shell/action-data.seq Stopping AM Callback notification attempts left 0 Callback notification trying http://nn.hdfs.offline:11000/oozie/callback?id=0000118-230724100647793-oozie-oozi-W@shell-af10&status=FAILED Callback notification to http://nn.hdfs.offline:11000/oozie/callback?id=0000118-230724100647793-oozie-oozi-W@shell-af10&status=FAILED succeeded Callback notification succeeded
07-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值