#!/usr/bin/env ruby # == this_cluster # Script used to launch multiple server instances. # It takes most of the same argument as the +thin+ script # plus the -n option to specify the number of servers to run. # # Also, you can store your options into a config file, create it like this: # thin_cluster config -C /var/www/my_app/current config # Then a config file will be created in /var/www/my_app/current/config/thin.yml # with the default options. # You can launch your 3 servers with: # thin_cluster start # And stop them with: # thin_cluster stop # # Run thin_cluster help to get help. require File.dirname(__FILE__) + '/../lib/thin' require 'thin/command' Thin.define_commands do program_name 'thin_cluster' version Thin::VERSION::STRING help 'Thin cluster monitoring tool for managing multiple Thin web servers' option :address, :short => :a, :default => '127.0.0.1', :message => 'Address to bind to', :param_name => 'ADDRESS' option :port, :short => :p, :default => 5000, :message => 'Port number to bind to', :param_name => 'PORT', :type => :int option :servers, :short => :n, :default => 3, :message => 'Number of servers to launch', :param_name => 'NUM', :type => :int option :environment, :short => :e, :default => 'production', :message => 'Rails environment', :param_name => 'ENVIRONMENT' option :log_file, :short => :l, :default => 'log/thin.log', :message => 'File to write log output to', :param_name => 'PATH' option :pid_file, :short => :P, :default => 'tmp/pids/thin.pid', :message => 'File to write the PID (use with -d)', :param_name => 'PATH' option :cwd, :short => :c, :param_name => 'PATH', :message => 'Change to dir before starting' option :user, :short => :u, :param_name => 'USER', :message => 'User to run the process as' option :group, :short => :g, :param_name => 'GROUP', :message => 'Group to run the process as' option :config, :short => :C, :default => 'config/thin.yml', :message => 'Config file', :param_name => 'PATH' option :timeout, :short => :T, :param_name => 'SEC', :message => 'Server and command timeout', :default => 60 option :trace, :short => :t, :message => 'Turn trace on' valid_options = [:address, :port, :environment, :log_file, :pid_file, :cwd, :servers, :config, :user, :group, :trace] command :start, Thin::Commands::Cluster::Start, :valid_options => valid_options command :stop, Thin::Commands::Cluster::Stop, :valid_options => valid_options command :restart, Thin::Commands::Cluster::Restart, :valid_options => valid_options command :config, Thin::Commands::Cluster::Config, :valid_options => valid_options end