Created
November 26, 2008 03:27
-
-
Save lukesutton/29259 to your computer and use it in GitHub Desktop.
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
| name: AppName | |
| port: 4020 | |
| environment: production | |
| size: 3 |
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
| #!/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