使用Java Service Wrapper的触发器

使用Java Service Wrapper的触发器根据服务器状态进行自动restart、shutdown等动作,以下是官方使用说明:

 

 

wrapper.filter.<x>.<n> Properties

Configuration Property Overview

wrapper.filter.trigger.<n> and wrapper.filter.action.<n>

A pair of wrapper.filter.trigger.<n> and wrapper.filter.action.<n> properties make it possible to filter the output of a JVM, and then perform some action whenever a specific trigger string is found. The filtering process works by comparing JVM console output against registered triggers until a match is found. At that point, the associated action is executed. Only the first matching trigger will be handled for any line of output. In each trigger/action pair, the "<n>" component of the property name is an integer number counting up from "1". By default, there can be no missing numbers. The wrapper.ignore_sequence_gaps property can optionally be set to allow gaps in the sequence.

wrapper.filter.trigger.<n> :

The trigger can be any string.

wrapper.filter.action.<n> :

If an action is omitted, it will default to RESTART .

Possible actions are followings:

  • RESTART : will stop the current JVM and then restart a new invocation.
  • SHUTDOWN : will stop the JVM as well as the Wrapper.
  • DUMP : will invoke a thread dump.
  • NONE : is useful because it will prevent any triggers with a higher number from being triggered.

Examples:

The following example will monitor the JVM output and then restart the JVM automatically whenever a java.lang.OutOfMemoryError is thrown to the console. Depending on where in an application the error is thrown, it is not always possible to trap and handle the error in a useful way from within the JVM.

Filters work by monitoring the console output of the JVM. In order for a trigger to be fired by an exception, the Java application must print the message being filtered to the console.

Example:
wrapper.filter.trigger.1=java.lang.OutOfMemoryError
wrapper.filter.action.1=RESTART

The next example demonstrates how to trigger a JVM restart whenever the string Error appears anywhere in the output, with the exception of the case where the string is part of the larger string IgnoreError .

Example:
wrapper.filter.trigger.1=IgnoreError
wrapper.filter.action.1=NONE
wrapper.filter.trigger.2=Error
wrapper.filter.action.2=RESTART

The string being filtered can contain spaces. But due to the way the configuration properties are loaded in general, any leading of trailing spaces will be trimmed when the property is loaded.

Example:
wrapper.filter.trigger.1=Restart me now.
wrapper.filter.action.1=RESTART
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值