Skip to content

Instantly share code, notes, and snippets.

View zzet's full-sized avatar
🎯
I may be slow to respond.

Andrew Kumanyaev zzet

🎯
I may be slow to respond.
View GitHub Profile
@zzet
zzet / gist:4004159
Created November 2, 2012 20:36
One news respond
{
"title": "Test news",
"description": "Some little description",
"body": "News content",
"url": "http://example.com/news/1",
"id": 1,
"autor": {
"name": "John",
"id": 1
},
{
"items":[
{
"title": "Test news",
"description": "Some little description",
"autor": {
"id": 1
},
"labels": [
{

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/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/dynamic_matchers.rb:55:in `method_missing': undefined method `devise' for #<Class:0x00000003091160> (NoMethodError)
from /rest/u/apps/gitlab/current/app/models/user.rb:41:in `<class:User>'
from /rest/u/apps/gitlab/current/app/models/user.rb:38:in `<top (required)>'
...
from /rest/u/apps/gitlab/current/app/models/issue.rb:20:in `include'
from /rest/u/apps/gitlab/current/app/models/issue.rb:20:in `<class:Issue>'
from /rest/u/apps/gitlab/current/app/models/issue.rb:19:in `<top (required)>'
...
from /rest/u/apps/gitlab/current/lib/api/notes.rb:6:in `<class:Notes>'
from /rest/u/apps/gitlab/current/lib/api/notes.rb:3:in `<module:API>'
use ActionDispatch::Static
use Rack::Lock
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007fcd3e3c7180>
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::DebugExceptions
use ActionDispatch::RemoteIp
use ActionDispatch::Static
use Rack::Lock
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007fc9db4e27b0>
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::DebugExceptions
use ActionDispatch::RemoteIp
@zzet
zzet / gist:7900439
Created December 10, 2013 21:22 — forked from dnagir/gist:1573414
  • This creates a 560mb ramdisk. Adjust the size accordingly. I think the number at the end of the command is the number of disk blocks. They are 2kb in size for me.
  • Restarting postgres is not necessary; you can create the ramdisk and tablespace while postgres is running.
  • You will lose all data in the ramdisk tablespace when you shut your machine down

  $ diskutil erasevolume HFS+ "postgres_ramdisk" `hdiutil attach -nomount ram://1165430`
  Started erase on disk1
  Unmounting disk
  Erasing
 Initialized /dev/rdisk1 as a 569 MB HFS Plus volume
def check(name = nil)
puts "\n=== Checking #{":" if name} #{name}"
e = rescuing do
yield
end
if e
puts e
puts
var args = require('system').args;
if (args.length === 3) {
var url = args[1];
var filename = args[2];
var page = require('webpage').create();
page.viewportSize = { width: 1024, height: 768 };
page.open(url, function () {
page.onConsoleMessage = function (msg) {
[1] pry(main)> start = Time.now; Rugged::Repository.new(Project.find_with_namespace('infrastructure/gitlab').repository.path_to_repo).diff("14798b8e686aafaa9ea3bc9b18294fefa54801f5", "211c433cd89ddc49b1f8c3ef6ba7bc366428a851").each_patch { |patch| puts; p patch.delta; puts; patch.hunks.first.lines.each {|l| p l } }; p "Finished in #{Time.now - start} seconds."
Namespace Load (69.9ms) SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."path" = 'infrastructure' LIMIT 1
Project Load (1.2ms) SELECT "projects".* FROM "projects" WHERE "projects"."namespace_id" = 3900 AND "projects"."path" = 'gitlab' LIMIT 1
Namespace Load (73.0ms) SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."id" = $1 ORDER BY "namespaces"."id" ASC LIMIT 1 [["id", 3900]]
"run native commnd in GRIT: 'rev-parse'; with options: '{}'; with args: [\"HEAD\"]"
"run native commnd in GRIT: 'rev-parse'; with options: '{}'; with args: [\"HEAD\"]"
#<Rugged::Diff::Delta:86854160 {old_file: {:oid=>"0000000000000000000000000000000