Tuesday, November 23, 2010

Debug Carbon server when it is started as a daemon

WSO2 Carbon Server can be run as a daemon on Unix/Linux systems. Say for instance that you need to remote debug the server when it is started as a daemon. This blogpost will be discussing $subject.

1) Open up the wrapper.conf file.

heshan@heshan-ThinkPad:~/Dev/customer/wso2esb-3.0.1/bin$ vim ../repository/conf/wrapper.conf

2) Add following entries to the wrapper.conf.

wrapper.java.additional.20=-Xdebug
wrapper.java.additional.21=-Xnoagent
wrapper.java.additional.22=-Djava.compiler=NONE
wrapper.java.additional.23=-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005

3) Start the ESB as a daemon.

heshan@heshan-ThinkPad:~/Dev/customer/wso2esb-3.0.1/bin$ ./wso2server.sh start
Starting WSO2 ESB v3.0.1...

4) Start the debugger.

5) Monitor the log.

heshan@heshan-ThinkPad:~/Dev/customer/wso2esb-3.0.1/bin$ tail -f ../repository/logs/wrapper.log
INFO | jvm 1 | 2010/11/24 11:35:09 | object space 84224K, 76% used [0x00007fbfcff20000,0x00007fbfd3e0dff0,0x00007fbfd5160000)
STATUS | wrapper | 2010/11/24 11:35:09 | <-- Wrapper Stopped STATUS | wrapper | 2010/11/24 11:45:46 | --> Wrapper Started as Daemon
WARN | wrapper | 2010/11/24 11:45:46 | ------------------------------------------------------------------------
WARN | wrapper | 2010/11/24 11:45:46 | The JVM is being launched with a debugger enabled and could possibly be
WARN | wrapper | 2010/11/24 11:45:46 | suspended. To avoid unwanted shutdowns, timeouts will be disabled,
WARN | wrapper | 2010/11/24 11:45:46 | removing the ability to detect and restart frozen JVMs.
WARN | wrapper | 2010/11/24 11:45:46 | ------------------------------------------------------------------------
STATUS | wrapper | 2010/11/24 11:45:46 | Launching a JVM...
INFO | jvm 1 | 2010/11/24 11:45:46 | Listening for transport dt_socket at address: 5005
INFO | jvm 1 | 2010/11/24 11:45:56 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
INFO | jvm 1 | 2010/11/24 11:45:56 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
INFO | jvm 1 | 2010/11/24 11:45:56 |
INFO | jvm 1 | 2010/11/24 11:45:56 | [2010-11-24 11:45:56,845] INFO - Main Initializing system...

Now you have successfully debugged the Carbon Server, when it is started as a daemon.

No comments: