Skip to content

Instantly share code, notes, and snippets.

@lukesutton
Created November 26, 2008 03:27
Show Gist options
  • Select an option

  • Save lukesutton/29259 to your computer and use it in GitHub Desktop.

Select an option

Save lukesutton/29259 to your computer and use it in GitHub Desktop.
name: AppName
port: 4020
environment: production
size: 3
#!/opt/local/bin/ruby
require "yaml"
module MerbCluster
OPTIONS = {
"environment" => "-e",
"port" => "-p",
"name" => "-n",
"size" => "-c"
}
def self.start
config_path = File.join(Dir.pwd, "config", "cluster.yml")
if File.exists?(config_path)
config = YAML.load_file(config_path)
args = OPTIONS.inject([]) do |memo, option|
memo << "#{option[1]} #{config[option[0]]}" if config[option[0]]
memo
end
puts `merb #{args.join(" ")}`
else
puts "Could not start cluster: cluster.yml is either missing, or you are not inside a merb application."
end
end
def self.stop
puts `merb -k`
end
def self.restart
puts stop
puts start
end
def self.fast_deploy
puts `merb --fast-deploy`
end
end
case ARGV[0]
when "start"
MerbCluster.start
when "stop"
MerbCluster.stop
when 'restart'
MerbCluster.restart
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment