環境はスタンドアロンを想定しています。
Byteman のダウンロードとインストール
個人的な趣味で恐縮ですが /opt 以下にインストールし、byteman とエイリアスをさせます。ダウンロードする URL やファイル名が変わらない限りは、BYTEMAN_VERSION を変更するだけで動作すると思います。
BYTEMAN_VERSION="2.1.3" BYTEMAN_BINARY="byteman-download-$BYTEMAN_VERSION" BYTEMAN_DOWNLOAD_URL="http://downloads.jboss.org/byteman/$BYTEMAN_VERSION/byteman-download-$BYTEMAN_VERSION-bin.zip" cd /opt wget -qO- -O tmp.zip $BYTEMAN_DOWNLOAD_URL && unzip tmp.zip && rm -f tmp.zip && ln -s $BYTEMAN_BINARY byteman
WidlFly 起動時に Byteman をアタッチ
以下の JVM 起動オプションを <WildFly のインストールディレクトリ>/bin/standalone.conf に追記します。
BYTEMAN_HOME=/opt/byteman BYTEMAN_RULE=/path/to/somerule.btm BYTEMAN_OPTS="-javaagent:$BYTEMAN_HOME/lib/byteman.jar=listener:true,boot:$BYTEMAN_HOME/lib/byteman.jar" if [ "x$BYTEMAN_RULE" != "x" ]; then BYTEMAN_OPTS="${BYTEMAN_OPTS},script:$BYTEMAN_RULE" fi BYTEMAN_OPTS="$BYTEMAN_OPTS -Dorg.jboss.byteman.transform.all -Dorg.jboss.byteman.debug" JAVA_OPTS="$BYTEMAN_OPTS $JAVA_OPTS"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RULE WILDFLY_STARTED | |
CLASS org.jboss.as.server.BootstrapListener | |
METHOD done | |
AT EXIT | |
IF TRUE | |
DO traceln("WildFly started with Byteman!") | |
ENDRULE | |
RULE WILDFLY_STOPPED | |
CLASS org.jboss.as.server.ApplicationServerService | |
METHOD stop | |
AT EXIT | |
IF TRUE | |
DO traceln("WildFly stopped with Byteman!") | |
ENDRULE |
# 起動時 [...] ... [...] INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.Beta1 "WildFly" started in 2058ms - Started 181 of 218 services (62 services are lazy, passive or on-demand) [...] INFO [stdout] (Controller Boot Thread) Default helper activated [...] INFO [stdout] (Controller Boot Thread) Installed rule using default helper : WILDFLY_STARTED [...] INFO [stdout] (Controller Boot Thread) WildFly started with Byteman! # 停止時 [...] ... [...] INFO [org.jboss.as] (MSC service thread 1-2) JBAS015950: WildFly 8.0.0.Beta1 "WildFly" stopped in 18ms [...] INFO [stdout] (MSC service thread 1-2) Installed rule using default helper : WILDFLY_STOPPED [...] INFO [stdout] (MSC service thread 1-2) WildFly stopped with Byteman!
0 件のコメント:
コメントを投稿