This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def all_replicas_in_sync?(verbose=false) | |
in_sync = true | |
# connect to the primary | |
mongo = Mongo::Connection.new(*MongoMapper.connection.primary) | |
db = mongo.db('local') | |
last_op=db.collection('oplog.rs').find.sort([['$natural',-1]]).limit(1).to_a[0] | |
db.collection('slaves').find().to_a.each do |slave| | |
opdiff = last_op['ts'].increment - slave['syncedTo'].increment | |
diff = (last_op['ts'].seconds - slave['syncedTo'].seconds)/1000.0 | |
in_sync = false if diff > 60 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trap('USR2') do | |
# reconnect to MongoDB with read_secondary reversed | |
result=MongoMapper.connection.instance_eval('@read_secondary = !@read_secondary') | |
logger.notice("#{Time.now}: now reading from #{result ? 'secondary' : 'primary'}") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bunny' | |
require 'logger' | |
class TestLoggerSubscribeMemleak | |
def initialize(msg_count=10_000) | |
@message_count = msg_count | |
@messages_to_write = msg_count | |
@connection = Bunny.new(:user=>"test_user", :pass=>"123456", :host=>"localhost", :vhost => "test", :port => 5672) | |
@connection.start | |
@channel = @connection.create_channel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bunny' | |
require 'logger' | |
class TestLoggerSubscribeMemleak | |
def initialize(msg_count=10_000) | |
@messages_to_write = msg_count | |
@message_count = msg_count | |
@connection = Bunny.new(:user=>"jbd_dev_reader", :pass=>"123456", :host=>"localhost", :vhost=>"jbd", :port=>5672) | |
@connection.start | |
@channel = @connection.create_channel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node.default.bar.tags = ['tag1-bar'] | |
file "/tmp/bar.txt" do | |
content lazy { node.bar.tags.join(',') } | |
end | |
ruby_block 'update second tag' do | |
block { node.default.bar.tags << 'tag2-bar' } | |
only_if { node.default.bar.tags << 'tag3-bar' } | |
notifies :create, 'file[/tmp/bar.txt]', :delayed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Converging 2 resources | |
Recipe: bar::default | |
* file[/tmp/bar.txt] action create[2014-10-16T23:14:38+00:00] INFO: Processing file[/tmp/bar.txt] action create (bar::default line 13) | |
[2014-10-16T23:14:38+00:00] INFO: file[/tmp/bar.txt] created file /tmp/bar.txt | |
- create new file /tmp/bar.txt[2014-10-16T23:14:38+00:00] INFO: file[/tmp/bar.txt] updated file contents /tmp/bar.txt | |
- update content in file /tmp/bar.txt from none to 4cee35 | |
--- /tmp/bar.txt 2014-10-16 23:14:38.033893771 +0000 | |
+++ /tmp/.bar.txt20141016-1369-yghu83 2014-10-16 23:14:38.033893771 +0000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'open-uri' | |
require 'rubygems' | |
require 'http' # this is the http gem | |
require 'faraday' | |
class ProxyTest | |
def initialize(url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default_redis_ip = 'localhost' | |
master_node = search(:node, 'role:redis-master').first | |
default_redis_ip = master_node.ipaddress unless master_node.nil? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include_recipe 'nginx' | |
resources(service: 'nginx').tap do |r| | |
r.action :enable | |
end | |
template '/etc/nginx/conf.d/my_file.conf' do | |
... | |
notifies :start, 'service[nginx]', :delayed | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= | |
require 'yaml' | |
ldap_info = { | |
'main' => { | |
'label' => @label, | |
'host' => @host, | |
'port' => @port, | |
'uid' => @uid, | |
'method' => @method, | |
'bind_dn' => @bind_dn, |
OlderNewer