Skip to content

Instantly share code, notes, and snippets.

@joshjdevl
joshjdevl / gist:26ddf5f5e8d9e495c87b
Last active August 29, 2015 14:02 — forked from shawnburke/gist:3750709
ubuntu ec2 bash prompt instance tag name
# these make the ec2 commands just work
export AWS_ACCESS_KEY=[AWS access key]
export AWS_SECRET_KEY=[AWS secret]
# fetch the instance id
export INSTANCE_ID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
#grep out the tag you're looking for, in this case "Name"
export APP_TAG=$(ec2dtag --region us-west-2 --filter "key=Name" --filter "resource-type=instance" --filter "resource-id=$INSTANCE_ID" | grep -oE "Name\\W+(.+)$" | grep -oE "\\W.+$")
# these make the ec2 commands just work
export AWS_ACCESS_KEY=[AWS access key]
export AWS_SECRET_KEY=[AWS secret]
# fetch the instance id
export INSTANCE_ID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
#grep out the tag you're looking for, in this case "Name"
export APP_TAG=$(ec2-describe-tags | grep $INSTANCE_ID | grep -oE "Name\\W+(.+)$" | grep -oE "\\W.+$")

WAL-E needs to be installed on all machines, masters and slaves.

How to install WAL-E

Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:

archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60
app = Dragonfly[:images]
app.configure_with(:imagemagick)
app.analyser.add :average_intensity do |temp_object|
(`python lib/simple_analyser.py #{temp_object.path}`.gsub("\n","").strip.to_f rescue 0.0)
end
app.processor.add :first_frame_of_gif_as_png do |temp_object|
tempfile = Tempfile.new(['dragonfly','.png'])
tempfile.binmode
tempfile.close
`convert #{temp_object.path}[0] #{tempfile.path}`