golden_brindle 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -5,7 +5,7 @@
5
5
  Tool to help start/stop/restart multiple unicorn servers to use behind a web servers like nginx. This app adds an option to specify a number of Unicorn worker processes to launch, a range of ports, and a configuration file for the cluster. Use "-h" to see command syntax.
6
6
 
7
7
  Configure cluster and write configuration file:
8
- golden_brindle brindle::configure (NOT implemented yet)
8
+ golden_brindle brindle::configure
9
9
 
10
10
  Start cluster:
11
11
  golden_brindle brindle::start
@@ -38,5 +38,7 @@ Stop cluster:
38
38
  == Copyright
39
39
 
40
40
  Copyright (c) 2010 Alexander Simonov. See LICENSE for details.
41
+
41
42
  Copyright (c) 2007 Zed A. Shaw
42
- Copyright (c) 2006 Bradley Taylor, bradley@fluxura.com
43
+
44
+ Copyright (c) 2006 Bradley Taylor, bradley@fluxura.com
data/TODO CHANGED
@@ -1 +1 @@
1
- Add configuration section for generate config file
1
+
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{golden_brindle}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alexander Simonov"]
12
- s.date = %q{2010-05-24}
12
+ s.date = %q{2010-05-27}
13
13
  s.default_executable = %q{golden_brindle}
14
14
  s.description = %q{Unicorn HTTP server clustering tool like mongrel_cluster for Mongrel}
15
15
  s.email = %q{alex@simonov.me}
@@ -68,7 +68,7 @@ module GoldenBrindle
68
68
 
69
69
  def config_keys
70
70
  @config_keys ||=
71
- %w(address host port cwd log_file pid_file environment servers daemon debug config_script num_workers timeout user group prefix preload listen)
71
+ %w(address host port cwd log_file pid_file environment servers daemon debug config_script workers timeout user group prefix preload listen)
72
72
  end
73
73
 
74
74
  def load_config
@@ -2,6 +2,61 @@ module Brindle
2
2
 
3
3
  class Configure < GemPlugin::Plugin "/commands"
4
4
  include GoldenBrindle::Command::Base
5
+
6
+ def configure
7
+ options [
8
+ ["-e", "--environment ENV", "Rails environment to run as", :@environment, ENV['RAILS_ENV'] || "development"],
9
+ ["-d", "--daemonize", "Run daemonized in the background", :@daemon, false],
10
+ ['', "--preload", "Preload application", :@preload, false],
11
+ ['-p', '--port PORT', "Which port to bind to (if set numbers of servers - start port number)", :@port, Unicorn::Const::DEFAULT_PORT],
12
+ ['-a', '--address ADDR', "Address to bind to", :@address, Unicorn::Const::DEFAULT_HOST],
13
+ ['-o', '--listen {HOST:PORT|PATH}',"listen on HOST:PORT or PATH, separeted by comma ", :@listen, nil] ,
14
+ ['-l', '--log FILE', "Where to write log messages", :@log_file, "log/unicorn.log"],
15
+ ['-P', '--pid FILE', "Where to write the PID", :@pid_file, "tmp/pids/unicorn.pid"],
16
+ ['-n', '--num-workers INT', "Number of Unicorn workers", :@workers, 4],
17
+ ['-N', '--num-servers INT', "Number of Unicorn listen records", :@servers, 1],
18
+ ['-t', '--timeout TIME', "Time to wait (in seconds) before killing a stalled thread", :@timeout, 60],
19
+ ['-c', '--chdir PATH', "Change to dir before starting (will be expanded)", :@cwd, Dir.pwd],
20
+ ['-D', '--debug', "Enable debugging mode", :@debug, false],
21
+ ['-C', '--config PATH', "Path to brindle configuration file", :@config_file, "config/brindle.yml"],
22
+ ['-S', '--script PATH', "Load the Unicorn-specific config file", :@config_script, nil],
23
+ ['', '--user USER', "User to run as", :@user, nil],
24
+ ['', '--group GROUP', "Group to run as", :@group, nil],
25
+ ['', '--prefix PATH', "URL prefix for Rails app", :@prefix, nil]
26
+ ]
27
+ end
28
+
29
+ def validate
30
+
31
+ valid_dir? File.dirname(@config_file), "Path to config file not valid: #{@config_file}"
32
+
33
+ if @config_script
34
+ valid_exists?(@config_script, "Unicorn-specific config file not there: #@config_script")
35
+ return false unless @valid
36
+ end
37
+
38
+ valid?(@prefix[0] == ?/ && @prefix[-1] != ?/, "Prefix must begin with / and not end in /") if @prefix
39
+ valid_dir? File.dirname(@log_file), "Path to log file not valid: #@log_file"
40
+ valid_dir? File.dirname(@pid_file), "Path to pid file not valid: #@pid_file"
41
+ valid_user? @user if @user
42
+ valid_group? @group if @group
43
+ return @valid
44
+ end
45
+
46
+ def run
47
+
48
+ file_options = {}
49
+
50
+ self.config_keys.each do |key|
51
+ key_val = self.instance_variable_get "@#{key}"
52
+ file_options[key] = key_val unless key_val.nil?
53
+ end
54
+
55
+ $stdout.puts "Writing configuration file to #{@config_file}."
56
+ File.open(@config_file,"w") {|f| f.write(file_options.to_yaml)}
57
+
58
+ end
59
+
5
60
  end
6
61
 
7
62
  end
@@ -3,7 +3,7 @@ module GoldenBrindle
3
3
  module Const
4
4
 
5
5
  # current version
6
- VERSION="0.0.2".freeze
6
+ VERSION="0.0.3".freeze
7
7
  # main banner
8
8
  BANNER = "Usage: golden_brindle <command> [options]".freeze
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: golden_brindle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Simonov
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-05-24 00:00:00 +03:00
12
+ date: 2010-05-27 00:00:00 +03:00
13
13
  default_executable: golden_brindle
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency