Skip to content

Instantly share code, notes, and snippets.

View skippy's full-sized avatar

Adam Greene skippy

  • San Juan County, WA
View GitHub Profile
Adam$ script/console
Loading development environment (Rails 2.3.4)
>> Mongo::VERSION
=> "0.15.1"
>> #MongoMapper::VERSION == 0.5.5
?> document = Class.new do
?> include MongoMapper::Document
>> set_collection_name 'duplicate_id_test'
>>
?> key :data, String
$ vm_stat
Mach Virtual Memory Statistics: (page size of 4096 bytes)
Pages free: 70104.
Pages active: 451608.
Pages inactive: 146907.
Pages speculative: 25993.
Pages wired down: 91606.
"Translation faults": 335008193.
Pages copy-on-write: 18718373.
Pages zero filled: 144137680.
c = MongoMapper.database.collection('system.js')
c.save(:_id => 'sdc_test', :value => Mongo::Code.new("function(x, y){ print('within method'); return x + y + 2}"))
MongoMapper.database.eval(Mongo::Code.new('sdc_test(x,y)', :x => 3, :y => 2))
# should see 'witin method' in /var/log/mongodb/output.log
#!/sbin/runscript
#
# Mongo init script for Gentoo
#
opts="start stop restart"
depend() {
use net
}
source "http://gemcutter.org"
gem "rails", "2.3.5"
gem 'mysql', '2.8.1'
gem "erubis", "2.6.5"
gem "rack"#, '1.0.1'
gem "resque", '1.5.0'
gem 'redis', '0.1.2'
require 'sinatra/base'
class ResqueWeb < Sinatra::Base
require 'resque/server'
use Rack::ShowExceptions
# Set the AUTH env variable to your basic auth password to protect Resque.
AUTH_PASSWORD = ENV['AUTH']
if AUTH_PASSWORD
Resque::Server.use Rack::Auth::Basic do |username, password|
module Resque
# Raised when a worker was killed while processing a job.
class DirtyExit < RuntimeError; end
class Worker
module KillPatch
module InstanceMethods
def unregister_worker_with_error_job(*args)
if self.job
# wrapping the new GridFileSystem so it has some of the nice helpers of the old GridFS class
# HACK: I set MongoMapper.database to the database I need for the particular call, so I can
# get away with simpler method calls....
module Mongo
class GridFSExt
def self.read(file_loc)
@gridfs = GridFileSystem.new(MongoMapper.database)
@gridfs.open(file_loc, "r") {|f| f.read } rescue nil
end
deploy@ip-nope /data/my_app/current $ ps auwx | grep unicorn
deploy 26724 0.0 1.8 235780 147988 ? S 01:15 0:06 unicorn_rails master (old) -c /data/my_app/shared/config/unicorn.rb -E staging -D
deploy 26753 0.0 1.5 211012 121636 ? S 01:16 0:00 unicorn_rails worker[0] -c /data/my_app/shared/config/unicorn.rb -E staging -D
deploy 26754 0.0 1.4 202880 112512 ? S 01:16 0:00 unicorn_rails worker[1] -c /data/my_app/shared/config/unicorn.rb -E staging -D
deploy 26755 0.0 1.4 205668 116276 ? S 01:16 0:00 unicorn_rails worker[2] -c /data/my_app/shared/config/unicorn.rb -E staging -D
deploy 26756 0.0 1.7 227096 137524 ? S 01:16 0:00 unicorn_rails worker[3] -c /data/my_app/shared/config/unicorn.rb -E staging -D
deploy 28472 0.0 1.8 235436 147920 ? S 02:19 0:06 unicorn_rails master -c /data/my_app/shared/config/unicorn.rb -E staging -D
deploy
Thu Apr 1 08:03:54 runQuery: mapp-staging.entries{ orig_relative_time: new Date(1263657120000), owner_id: 22, owner_type: "Place::Visit", value: 83.0 }
Thu Apr 1 08:03:54 query mapp-staging.entries ntoreturn:1 reslen:289 nreturned:1 1ms
Thu Apr 1 08:03:54 runQuery: mapp-staging.entries{ orig_relative_time: new Date(1263646920000), owner_id: 22, owner_type: "Place::Visit", value: 119.0 }
Thu Apr 1 08:03:54 query mapp-staging.entries ntoreturn:1 reslen:289 nreturned:1 1ms
Thu Apr 1 08:03:54 runQuery: mapp-staging.entries{ orig_relative_time: new Date(1263639900000), owner_id: 22, owner_type: "Place::Visit", value: 129.0 }
Thu Apr 1 08:03:54 query mapp-staging.entries ntoreturn:1 reslen:289 nreturned:1 1ms
Thu Apr 1 08:03:54 runQuery: mapp-staging.entries{ orig_relative_time: new Date(1263627420000), owner_id: 22, owner_type: "Place::Visit", value: 107.0 }
Thu Apr 1 08:03:54 query mapp-staging.entries ntoreturn:1 reslen:289 nreturned:1 1ms
Thu Apr 1 08:03:54 runQuery: mapp-staging.downloads{ owner_id: 2