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
#! /bin/sh | |
# Generic script for running ruby scripts as daemons using | |
# jsvc and a java class to control the daemon. | |
# | |
# Contains common parameters and start/stop | |
# Things you'll need to set on a per script/daemon basis: | |
# SCRIPT_NAME | |
# | |
# Things you can set: |
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
public class JRubyDaemon implements Daemon { | |
private Ruby runtime; | |
private Thread thread; | |
private RubyModule appModule; | |
private boolean debug; | |
private RubyModule daemon; | |
public void init(DaemonContext arguments) throws Exception { |
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
## Knife plugin to set node environment | |
# See http://wiki.opscode.com/display/chef/Environments | |
# | |
## Install | |
# Place in .chef/plugins/knife/set_environment.rb | |
# | |
## Usage | |
# Nick-Stielaus-MacBook-Pro:chef-repo nstielau$ knife node set_environment mynode.net my_env | |
# Looking for mynode.net | |
# Setting environment to my_env |
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
## mysql::master | |
ruby_block "store_mysql_master_status" do | |
block do | |
node.set[:mysql][:master] = true | |
m = Mysql.new("localhost", "root", node[:mysql][:server_root_password]) | |
m.query("show master status") do |row| | |
row.each_hash do |h| | |
node.set[:mysql][:master_file] = h['File'] | |
node.set[:mysql][:master_position] = h['Position'] | |
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
http://www.agileweboperations.com/chef-rvm-ruby-enterprise-edition-as-default-ruby | |
http://www.christophersamuelson.com/2010/10/22/chef-rvm-capistrano-bundler/ | |
http://blog.ninjahideout.com/posts/a-guide-to-a-nginx-passenger-and-rvm-server | |
http://brandontilley.com/2011/01/29/serving-rails-apps-with-rvm-nginx-unicorn-and-upstart.html | |
http://brandontilley.com/2011/01/29/rvm-unicorn-and-upstart.html | |
Chef workflow | |
# Install cookbook from opscode community site. (Automatically commits to local repo) | |
knife cookbook site install <COOKBOOK_NAME> |
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 'celluloid' | |
require 'logger' | |
require 'uuid' | |
require 'sinatra/base' | |
# This is just a simple demo of a possible Pool implementation for Celluloid | |
# The sinatra interface exists just to do some testing of crashing workers and the like | |
# TODO | |
# Create a busy worker registry of some kind |
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 'celluloid' | |
require 'logger' | |
require 'uuid' | |
require 'sinatra/base' | |
# This is just a simple demo of a possible Pool implementation for Celluloid | |
# The sinatra interface exists just to do some testing of crashing workers and the like | |
# TODO | |
# Create a busy worker registry of some kind |
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 'thread' | |
require 'celluloid' | |
$q = Queue.new | |
class A | |
include Celluloid | |
def add | |
loop do |
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 'rubygems' | |
require 'celluloid' | |
class Charlie | |
include Celluloid | |
def initialize(friend) | |
@nemesis = friend | |
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
# NOTE: original gist that this is based on is available here: https://gist.github.com/1143369 | |
require 'celluloid' | |
require 'logger' | |
require 'uuid' | |
require 'sinatra/base' | |
# This is just a simple demo of a possible Pool implementation for Celluloid | |
# The sinatra interface exists just to do some testing of crashing workers and the like |
OlderNewer