Last active
November 22, 2017 15:11
-
-
Save crakaC/45daaa0af7685f2e49637ceb8fefaa00 to your computer and use it in GitHub Desktop.
puma, sidekiqのheap_dumpをとる(gem 'rbtrace'が必要)
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
#!/bin/bash -e | |
cd ~/live | |
sidekiq_pid=`ps aux | grep sidekiq | grep -v grep | awk '{print $2}'` | |
puma_pid=`ps aux | grep puma | grep -v grep | awk '{print $2}'` | |
/home/mastodon/.rbenv/shims/bundle exec rbtrace -p $puma_pid --timeout 30 -e 'Thread.new{GC.start;require "objspace";io=File.open("/tmp/puma.dump", "w"); ObjectSpace.dump_all(output: io); io.close}' | |
/home/mastodon/.rbenv/shims/bundle exec rbtrace -p $sidekiq_pid --timeout 30 -e 'Thread.new{GC.start;require "objspace";io=File.open("/tmp/sidekiq.dump", "w"); ObjectSpace.dump_all(output: io); io.close}' | |
# ちょっと待つと吉 | |
sleep 5 | |
rm /tmp/dump.tar.gz | |
tar -zcf /tmp/dump.tar.gz /tmp/puma.dump /tmp/sidekiq.dump | |
rm /tmp/*.dump |
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
# 吐き出しきれないときのために | |
sysctl kernel.msgmax=1073741824 | |
sysctl kernel.msgmnb=1073741824 |
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
#!/bin/bash | |
# mastodon-web, mastodon-sidekiq起動後に実行する | |
cd ~/live | |
sidekiq_pid=`ps aux | grep sidekiq | grep -v grep | awk '{print $2}'` | |
puma_pid=`ps aux | grep puma | grep -v grep | awk '{print $2}'` | |
/home/mastodon/.rbenv/shims/bundle exec rbtrace -p $puma_pid -e 'Thread.new{require "rbtrace"; require "objspace";ObjectSpace.trace_object_allocations_start;}' | |
/home/mastodon/.rbenv/shims/bundle exec rbtrace -p $sidekiq_pid -e 'Thread.new{require "rbtrace"; require "objspace";ObjectSpace.trace_object_allocations_start;}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment