Skip to content

Instantly share code, notes, and snippets.

Avatar

David Czarnecki czarneckid

View GitHub Profile
@czarneckid
czarneckid / Zero downtime deploys with gunicorn.markdown
Last active Aug 31, 2016
Zero downtime deploys with gunicorn
View Zero downtime deploys with gunicorn.markdown

Zero downtime deploys with gunicorn

Below are the actual files we use in one of our latest applications at Agora Games to achieve zero downtime deploys with gunicorn. 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).

Salient points for each file:

  • gunicorn.py: The pre_fork function looks for gunicorn's old PID file in the proper file and sends the proper QUIT signal to the old process once the new process is running.
  • sv-gunicorn-run.jinja: This is the runit template we use in our Salt-managed infrastructure for handling the application process management. You could just as easily convert this to a non-templatized version.
View gist:11305899
class Fish
def 🔪
puts "🍣"
end
end
🐟 = Fish.new
🐟.🔪
@czarneckid
czarneckid / redis_lua_eval.rb
Last active Jan 3, 2016
Redis, Lua and global functions Redis 2.8.3 redis-rb 3.0.6
View redis_lua_eval.rb
require 'redis'
redis = Redis.new
redis.script(:flush)
redis.flushdb
hello_name_lua_script = <<-HELLO_NAME_LUA_SCRIPT
local function hello_name(name)
return("Hello " .. name)
end
View Preferences.sublime-settings
{
"auto_complete": false,
"color_scheme": "Packages/Theme - itg.flat/itg.Monokai.tmTheme",
"detect_slow_plugins": false,
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
@czarneckid
czarneckid / Preferences.sublime-settings
Created Dec 16, 2013
Phoenix Dark with base16-bright theme
View Preferences.sublime-settings
{
"auto_complete": false,
"color_scheme": "Packages/Base16 Color Schemes/base16-bright.dark.tmTheme",
"detect_slow_plugins": false,
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
@czarneckid
czarneckid / sample_controller.rb
Created Dec 5, 2013
UITextView and horizontal scrolling?
View sample_controller.rb
class SampleController < UIViewController
def viewDidLoad
super
self.view.backgroundColor = UIColor.whiteColor
@text_view = UITextView.alloc.initWithFrame(UIScreen.mainScreen.applicationFrame)
@text_view.text = sample_text
@text_view.editable = false
@text_view.showsHorizontalScrollIndicator = true
@czarneckid
czarneckid / init.sls
Created Oct 10, 2013
SaltStack application runit configuration
View init.sls
# Setup the application's runit directory
/etc/sv/application:
file.directory:
- mode: 0755
- user: someuser
- group: someuser
- recurse:
- user
- group
- mode
@czarneckid
czarneckid / gist:6524608
Created Sep 11, 2013
Ruby Attr Antipattern timing
View gist:6524608
class Demo
def initialize(something)
@something = something
end
def based_on_something
@something * 2
end
end
View Rails 4 Upgrade Notes.md

Rails 4 Upgrade Notes

I recently completed our upgrade to Rails 4. Below are various notes and links that may help you if you are upgrading your application to Rails 4. YMMV.

Overview

There is a good Rails Guide on upgrading, with a specific section on upgrading from Rails 3.2 to Rails 4.0. First, a bit about our specific application and the technologies used, pre-Rails 4 upgrade:

  • Rails 3.2.14
  • Ruby 2.0.0-p247
View application-notes-zero-downtime-deploys-unicorn-nginx-runit-rvm-chef.md

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: