Skip to content

Instantly share code, notes, and snippets.

View ezmobius's full-sized avatar

Ezra Zygmuntowicz ezmobius

View GitHub Profile
#!/bin/sh
# This script should live in /engineyard/bin/ and be named monit_merb
mdk_merb() {
if [ -e "${PIDFILE}" ]; then
OLDPID=`cat ${PIDFILE}`
if [ ! -d /proc/$OLDPID ]; then
rm -f $PIDFILE
OLDPID=""
fi
#!/bin/bash
# /engineyard/bin/merb_thin
# This script starts and stops a named thin server on a specified socket
# This script belongs in /engineyard/bin/thin
# Do not forget to ensure this script is executable:
# $ chmod a+x /engineyard/bin/merb_thin
export PATH=/bin:/usr/bin:/usr/local/bin:/usr/local:/opt/bin:$PATH
# /etc/monit.d/merb.<%= @appname %>.monitrc
<% (@merb_base_port).upto(@merb_base_port + (@merb_instance_count - 1)) do |port| %>
check process merb_<%= @appname %>_<%= port %>
with pidfile /var/run/engineyard/<%= @appname %>/merb.<%= port %>.pid
start program = "/engineyard/bin/merb start <%= @appname %> <%= @port %> <%= @environment %>" as uid <%= @username %> and gid <%= @username %>
stop program = "/engineyard/bin/merb stop <%= @appname %> <%= @port %> <%= @environment %>" as uid <%= @username %> and gid <%= @username %>
if totalmem is greater than 80.0 MB for 2 cycles then restart # eating up memory?
group merb_<%= @appname %>
<% end %>
#!/bin/bash
# /engineyard/bin/merb_thin
# This script starts and stops a named thin server on a specified socket
# This script belongs in /engineyard/bin/thin
# Do not forget to ensure this script is executable:
# $ chmod a+x /engineyard/bin/merb_thin
export PATH=/bin:/usr/bin:/usr/local/bin:/usr/local:/opt/bin:$PATH
if !Merb::Controller._subclasses.include?(cnt)
raise Merb::ControllerExceptions::NotFound, "Controller '#{cnt}' not found"
end
# sudoers file.
# Reset environment by default
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
# Defaults:%wheel !env_reset
# Host alias specificationrs to export specific variables
# Defaults:%users env_keep=TZ
# User alias specification
@ezmobius
ezmobius / cli.rb
Created March 1, 2009 23:54 — forked from fujin/cli.rb
def run
AMQP.logging = true
EM.run do
agent = Nanite::Agent.start(@config)
agent.register(Opscode::OhaiActor.new, 'state')
agent.register(Opscode::ChefActor.new, 'control')
agent.send :advertise_services
end
end
require 'redis'
module Nanite
class State
include Enumerable
# this class encapsulates the state of a nanite system using redis as the
# data store. here is the schema, for each agent we store a number of items,
# for a nanite with the identity: nanite-foobar we store the following things:
#
def on_time_value
attendances.inject(0) do |sum, attendance|
sum += attendance.late? ? 0 : 5
end
end
redis.sort 'index', :by => 'weight_*',
:order => 'DESC ALPHA',
:limit => [0,10],
:get => 'obj_*'
VS
redis.sort "SORT index BY weight_* GET obj_* DESC ALPHA LIMIT 0 10"