Skip to content

Instantly share code, notes, and snippets.

View phumpal's full-sized avatar
🌮

Patrick Humpal phumpal

🌮
  • Northern California
View GitHub Profile
if node[:ec2][:ephemeral][:devices].include?("/dev/sdd")
# if we also have sdd and sde, raid0 them and put data there
data_raid_block_devs = [ "/dev/sdd", "/dev/sde" ]
data_raid_mountpoint = "/mnt/cassandra_data"
data_raid_dev = "/dev/md0"
data_file_dir = Array(node[:cassandra][:data_file_dirs]).first
package "mdadm" do
action :install
end
@lusis
lusis / create_ebs.rb
Created December 2, 2010 06:58
Small script to setup ec2 instances and EBS volumes for my blog post series
# Create 4 volumes and attach them to hdb
%w[sdi sdj sdk sdl].each do |dev|
volume = AWS.volumes.new :device => "/dev/#{dev}", :size => 5, :availability_zone => hdb.availability_zone
volume.server = hdb
volume.save
end
Bluepill.application("THEAPP") do | app |
["mail"].each do |worker_type|
app.process(worker_type+"_worker") do |process|
process.group = "workers"
#Refactor this into using rails_env and rails_root variables
process.start_command = "cd /home/........production; QUEUE="+worker_type+" rake environment resque:work RAILS_ENV=production"
process.daemonize = true
process.pid_file = "/tmp/"+worker_type+"_worker.pid"
process.start_grace_time = 3.seconds
process.stop_grace_time = 5.seconds
@chris
chris / nodejs_recipe.rb
Created May 13, 2011 05:55
Chef recipe to install node.js on Engine Yard AppCloud
#
# Cookbook Name:: nodejs
# Recipe:: default
#
# Build and install node.js
#
if ['app','app_master','solo'].include?(node[:instance_role])
version_tag = "v0.4.8"
source_base_dir = "/data/nodejs"
@andreacfm
andreacfm / resque_worker_upstart.sh
Created October 3, 2011 15:33
resque workers via upstart runned by unpriviledge user
#!upstart
description "Workers [resque]"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn
respawn limit 99 5
console none
@johnrees
johnrees / redis.erb
Created October 2, 2012 12:37
Monit template files
check process redis
start program = "/usr/bin/redis-server /etc/redis/redis.conf"
stop program = "/usr/bin/redis-cli -p 6379 shutdown"
with pidfile /var/run/redis.pid
@diogok
diogok / etcd-to-env.sh
Last active December 6, 2015 07:55
Register running docker containers and vagrant vms into ETCD and reads them out into ENVironment vars.
#!/bin/bash
# this script tries to turn your etcd into env vars
[[ ! $EHOST ]] && EHOST="$(hostname -I | awk '{ print $1 }')"
[[ ! $EPORT ]] && EPORT=4001
[[ ! $ETCD ]] && ETCD="http://${EHOST}:$EPORT"
ETCD_FILE="/tmp/$(date +%s).etcd.json"
wget "$ETCD/v2/keys/?recursive=true" -O $ETCD_FILE
@mrlesmithjr
mrlesmithjr / Nginx Dashboard
Last active December 10, 2015 14:10
Logstash Nginx Dashboard
{
"title": "Nginx",
"services": {
"query": {
"list": {
"0": {
"id": 0,
"color": "#7EB26D",
"alias": "Exclude from Top Page Requests",
"pin": false,
@kenn
kenn / gist:5105175
Last active December 14, 2015 15:08
Unicorn memory usage improvement with Ruby 2.0.0

Unicorn memory usage improvement with Ruby 2.0.0

Here's a preliminary experiment to see how much memory is saved with the new copy-on-write friendly (bitmap marking) GC.

Calculated by memstats.rb https://gist.github.com/kenn/5105061 on Debian x86_64.

Master process:

# ./memstats.rb 20547
@natew
natew / deploy.rb
Last active December 16, 2015 17:39
deploy.rb rolling restart with unicorn deploy.rb in your rails app /config/deploy.rb on your server: /etc/unicorn/site.conf /etc/init.d/unicorn /etc/nginx/sites-available/sitename.conf
require "bundler/capistrano"
load 'deploy/assets'
# Pretty colors
require 'capistrano_colors'
# rbenv and ssh forwarding
set :default_environment, { 'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH" }
set :default_run_options, { :pty => true, :shell => '/bin/zsh' }
set :ssh_options, { :forward_agent => true }