Skip to content

Instantly share code, notes, and snippets.

View lee's full-sized avatar

Lee Bankewitz lee

View GitHub Profile
//Example data...
{
LivePicsImpressionsDaily : { //column family
54 : { // row (pic id)
timeuuid : 54 // 54 views on this day
// ... other columns, one for each day (or 10-min period)
}
}
}
@lee
lee / gist:1435031
Created December 5, 2011 19:46
Monitor unicorn for memory usage
-- monitor memory usage
check process unicorn_worker0
with pidfile unicorn_worker0.pid
if mem > 280.0 MB for 2 cycles then exec "/bin/bash -c '/bin/kill -3 `cat unicorn_worker0.pid` && sleep 1'"
-- write a worker pid in unicorns after_fork |server, worker|
worker_pid = File.join(File.dirname(server.config[:pid]), "unicorn_worker#{worker.nr}.pid")
File.open(worker_pid, "w") { |f| f.puts Process.pid }
@lee
lee / maintenance_migrator.rb
Created October 5, 2011 12:42
One way to use Rails Migrations for things other than db:migrate
# This stuff is from a Rails 2 app, but I don't think *too* much has changed in 3.0
class MaintenanceMigrator < ActiveRecord::Migrator
def self.schema_migrations_table_name
"#{super}_maintenance"
end
end
# To Run
MaintenanceMigrator.migrate("db/maintenance/")
ey web disable -e weplay_p # SITE DOWN
ey ssh -e weplay_p --utilities=redisslave # ssh redisslave
sudo monit stop redis # stop redis slave
ey ssh -e weplay_p --utilities=redismaster # ssh redismaster
sudo monit stop redis # stop redis master
sudo monit start redis # start redis master
tail -f /data/redis/redis.log # wait for log output to indicate dataset is loaded
# This should take about 4 minutes
[x] ey recipes upload -e CLOUD_ENV # upload the latest recipes, including the redis upgrade
[x] ey web disable -e CLOUD_ENV # take the site down
[x] ey rebuild -e CLOUD_ENV # run all of EYs recipes (installs a gem)
# and our custom recipes (install redis)
[x] sudo monit stop redis on redisslave # stop redis 1.2.2, use ps to ensure it has exited
[x] sudo monit stop redis on redismaster
# code in cookbooks/main/definitions/ey_cloud_report.rb
if node[:output_cloud_reporting_locally]
 # output locally with "puts" statements
else
 # use engineyard's specialized reporting
end
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local LIGHT_GREEN="\[\033[1;32m\]"