Skip to content

Instantly share code, notes, and snippets.

@duduribeiro
duduribeiro / gist:3777294
Created September 24, 2012 17:54 — forked from brunoandradd/gist:3777274
Config nginx com php/ruby
worker_processes 3;
events {
worker_connections 1024;
}
http {
passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.7;
passenger_ruby /usr/local/bin/ruby;

Zero downtime deploys with unicorn + nginx + runit + rvm + chef

Below are the actual files we use in one of our latest production applications at Agora Games to achieve zero downtime deploys with unicorn. You've probably already read the GitHub blog post on Unicorn and would like to try zero downtime deploys for your application. I hope these files and notes help. I am happy to update these files or these notes if there are comments/questions. YMMV (of course).

Other application notes:

  • Our application uses MongoDB, so we don't have database migrations to worry about as with MySQL or postgresql. That does not mean that we won't have to worry about issues with the database with indexes being built in MongoDB or what have you.
  • We use capistrano for deployment.

Salient points for each file:

#!/usr/bin/env ruby
require 'time'
require 'logger'
require 'rubygems'
require 'pingdom-client'
require 'active_support/core_ext/numeric/time' # time extensions, e.g., 5.days
require 'stashboard'
TIME_FORMAT = "%Y-%m-%d %H:%M:%S %Z" # YYYY-MM-DD HH:MM:SS ZZZ
#!/bin/sh
# Sublime Text 3 install with Package Control
# http://simonewebdesign.it/blog/install-sublime-text-3-on-fedora-20/
# Run this script with:
# $ curl LINK_TO_THIS_SCRIPT | sh
curl -o ~/st3.tar.bz2 http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3059_x64.tar.bz2

Deploy Rails 4 app with Dokku on DigitalOcean

Install dokku

First create a Ubuntu 13.04 x64 droplet on DigitalOcean Control Panel

Then ssh with root account, run this in termianl:

$ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
# Install redis with homebrew :)
$ brew install redis
# Create a deamon
$ sudo vim /Library/LaunchDaemons/io.redis.redis-server.plist
# Paste the following content
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@duduribeiro
duduribeiro / introrx.md
Created December 19, 2015 18:09 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@duduribeiro
duduribeiro / woodo
Created February 2, 2016 03:51 — forked from 1995eaton/woodo
sudo woodo
#!/bin/sh
if [ $EUID -ne 0 ]; then
echo "It's a weird tree."
else
cat << "EOF"
@@@ @@@
@///@ /@@ @; @
@/ //@ / ;@ @;; @
@// ///@ @ ;;@ @;;;;;@
@duduribeiro
duduribeiro / nginx.conf
Created February 6, 2017 17:19 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048