Server applications (like Rails apps) cause performance problems, deadlock or memory swapping from time to time. But it’s difficult to reproduce such kind of problems. sigdump makes it possible to get information from a running process without restarting. Just sending SIGCONT signal will dump backtrace and memory profile to /tmp/sigdump-<pid>.log file.
sigdump dumps following information (see also Sample output):
Backtrace of all threads
Number of allocated objects per class
GC profiler reports if GC profiler is enabled (GC::Profiler.enable is called)
Stacktrace of Java threads for each Ruby threads if the runtime is JRuby
Install
Just install sigdump gem and add require 'sigdump/setup' line to your code. Or you can use Bundler as following:
You need to change the default signal (SIGCONT) because Rescue traps SIGCONT and it conflicts with sigdump.
To change the signal, set name of a signal to SIGDUMP_SIGNAL environment variable. For Rails, you can add following lines to environment.rb file:
Send SIGCONT signal to the Ruby process. It dumps backtrace and memory profile to /tmp/sigdump-<pid>.log file.
$ kill -CONT <pid>
$ cat /tmp/sigdump-<pid>.log
Set SIGDUMP_SIGNAL environment variable to change the signal (default: SIGCONT).
Set SIGDUMP_PATH environment variable to change the output path (default: /tmp/sigdump-<pid>.log). You can set “-“ here to dump to STDOUT, or “+” to STDERR.
sigdump
In short: SIGQUIT of Java VM for Ruby.
Server applications (like Rails apps) cause performance problems, deadlock or memory swapping from time to time. But it’s difficult to reproduce such kind of problems.
sigdumpmakes it possible to get information from a running process without restarting. Just sendingSIGCONTsignal will dump backtrace and memory profile to/tmp/sigdump-<pid>.logfile.sigdumpdumps following information (see also Sample output):GC::Profiler.enableis called)Install
Just install
sigdumpgem and addrequire 'sigdump/setup'line to your code. Or you can use Bundler as following:Note for Resque:
You need to change the default signal (
SIGCONT) because Rescue trapsSIGCONTand it conflicts with sigdump. To change the signal, set name of a signal toSIGDUMP_SIGNALenvironment variable. For Rails, you can add following lines toenvironment.rbfile:Usage
Send
SIGCONTsignal to the Ruby process. It dumps backtrace and memory profile to/tmp/sigdump-<pid>.logfile.Set
SIGDUMP_SIGNALenvironment variable to change the signal (default: SIGCONT).Set
SIGDUMP_PATHenvironment variable to change the output path (default: /tmp/sigdump-<pid>.log). You can set “-“ here to dump to STDOUT, or “+” to STDERR.Sample outout