This file contains 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 | |
# 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 |
This file contains 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/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 |
This file contains 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
# /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 %> |
This file contains 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/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 |
This file contains 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
if !Merb::Controller._subclasses.include?(cnt) | |
raise Merb::ControllerExceptions::NotFound, "Controller '#{cnt}' not found" | |
end |
This file contains 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
# 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 |
This file contains 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 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 |
This file contains 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 '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: | |
# |
This file contains 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 on_time_value | |
attendances.inject(0) do |sum, attendance| | |
sum += attendance.late? ? 0 : 5 | |
end | |
end |
This file contains 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
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" |
OlderNewer