public
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
Search Repo:
Fix -s option not being included in generated config file, fixes #37.
macournoyer (author)
Sat Feb 09 13:05:09 -0800 2008
commit  be7b246818985588590e4b520e46d2c81ed734b7
tree    da0639afba3abd033cbb2e25f1ab8bb43029fef0
parent  704af3973c881cfa99c6265591d7face9e8a7701
...
1
 
2
3
4
...
1
2
3
4
5
0
@@ -1,4 +1,5 @@
0
 == 0.7.0 Bionic Pickle release
0
+ * Fix -s option not being included in generated config file, fixes #37.
0
  * Add Swiftiply support. Use w/ the --swiftiply (-y) option in the thin script,
0
    closes #28 [Alex MacCaw]
0
 
...
5
6
7
8
9
10
 
 
 
 
11
12
13
14
15
16
17
18
19
20
 
 
 
21
22
23
...
25
26
27
 
 
28
29
30
...
39
40
41
42
 
43
44
45
...
51
52
53
54
 
55
56
57
...
89
90
91
92
93
 
 
94
95
96
97
98
...
103
104
105
106
107
 
 
108
109
 
110
111
 
112
113
114
...
5
6
7
 
 
 
8
9
10
11
12
13
 
 
 
 
 
 
 
 
14
15
16
17
18
19
...
21
22
23
24
25
26
27
28
...
37
38
39
 
40
41
42
43
...
49
50
51
 
52
53
54
55
...
87
88
89
 
 
90
91
92
93
94
95
96
...
101
102
103
 
 
104
105
106
 
107
108
 
109
110
111
112
0
@@ -5,19 +5,15 @@
0
     # * Inject the port or socket number in the pid and log filenames.
0
     # Servers are started throught the +thin+ command-line script.
0
     class Cluster < Controller
0
- # Number of servers in the cluster.
0
- attr_accessor :size
0
-
0
+ # Cluster only options that should not be passed in the command sent
0
+ # to the indiviual servers.
0
+ CLUSTER_OPTIONS = [:servers, :only]
0
+
0
       # Create a new cluster of servers launched using +options+.
0
       def initialize(options)
0
- @options = options.merge(:daemonize => true)
0
- @size = @options.delete(:servers)
0
- @only = @options.delete(:only)
0
-
0
- if socket
0
- @options.delete(:address)
0
- @options.delete(:port)
0
- end
0
+ super
0
+ # Cluster can only contain daemonized servers
0
+ @options.merge!(:daemonize => true)
0
       end
0
     
0
       def first_port; @options[:port] end
0
@@ -25,6 +21,8 @@
0
       def socket; @options[:socket] end
0
       def pid_file; @options[:pid] end
0
       def log_file; @options[:log] end
0
+ def size; @options[:servers] end
0
+ def only; @options[:only] end
0
 
0
       def swiftiply?
0
         @options.has_key?(:swiftiply)
0
@@ -39,7 +37,7 @@
0
       def start_server(number)
0
         log "Starting server on #{server_id(number)} ... "
0
       
0
- run :start, @options, number
0
+ run :start, , number
0
       end
0
   
0
       # Stop the servers
0
@@ -51,7 +49,7 @@
0
       def stop_server(number)
0
         log "Stopping server on #{server_id(number)} ... "
0
       
0
- run :stop, @options, number
0
+ run :stop, , number
0
       end
0
     
0
       # Stop and start the servers.
0
@@ -89,8 +87,8 @@
0
       
0
       private
0
         # Send the command to the +thin+ script
0
- def run(cmd, options, number)
0
- cmd_options = options.dup
0
+ def run(cmd, number)
0
+ cmd_options = @options.reject { |option, value| CLUSTER_OPTIONS.include?(option) }
0
           cmd_options.merge!(:pid => pid_file_for(number), :log => log_file_for(number))
0
           if socket
0
             cmd_options.merge!(:socket => socket_for(number))
0
0
0
@@ -103,12 +101,12 @@
0
         end
0
       
0
         def with_each_server
0
- if @only
0
- yield @only
0
+ if only
0
+ yield only
0
           elsif socket || swiftiply?
0
- @size.times { |n| yield n }
0
+ size.times { |n| yield n }
0
           else
0
- @size.times { |n| yield first_port + n }
0
+ size.times { |n| yield first_port + n }
0
           end
0
         end
0
       
...
19
20
21
 
 
 
 
 
22
23
24
...
19
20
21
22
23
24
25
26
27
28
29
0
@@ -19,6 +19,11 @@
0
     
0
       def initialize(options)
0
         @options = options
0
+
0
+ if @options[:socket]
0
+ @options.delete(:address)
0
+ @options.delete(:port)
0
+ end
0
       end
0
     
0
       def start
...
10
11
12
13
 
14
15
16
...
10
11
12
 
13
14
15
16
0
@@ -10,7 +10,7 @@
0
       TEMPLATE = File.dirname(__FILE__) + '/service.sh.erb'
0
     
0
       def initialize(options)
0
- @options = options
0
+ super
0
       
0
         raise PlatformNotSupported, 'Running as a service only supported on Linux' unless Thin.linux?
0
       end
...
19
20
21
22
23
24
25
26
27
28
...
120
121
122
123
124
125
126
127
128
129
130
...
19
20
21
 
 
 
 
22
23
24
...
116
117
118
 
 
 
 
 
119
120
121
0
@@ -19,10 +19,6 @@
0
     @cluster.send(:include_server_number, 'thin.pid', 3000).should == 'thin.3000.pid'
0
   end
0
   
0
- it "should exclude :servers option" do
0
- @cluster.options.should_not have_key(:servers)
0
- end
0
-
0
   it 'should call each server' do
0
     calls = []
0
     @cluster.send(:with_each_server) do |port|
0
@@ -120,11 +116,6 @@
0
                            :only => 3001
0
                           )
0
     @cluster.silent = true
0
- end
0
-
0
- it "should exclude :servers and :only options" do
0
- @cluster.options.should_not have_key(:servers)
0
- @cluster.options.should_not have_key(:only)
0
   end
0
   
0
   it 'should call only specified server' do

Comments

    No one has commented yet.