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:
Allow disabling signal handling in Server with :signals => false
macournoyer (author)
Thu Apr 03 21:03:06 -0700 2008
commit  6cb32ec3f90457e96cdc541a387bf50e07a6ecad
tree    f00a5f8771386f5b8619b3c6aaec75bda48f2f77
parent  01dece1c2b32d9b12d1d2ee64aa78917f2ddaae1
...
1
 
2
3
4
...
1
2
3
4
5
0
@@ -1,4 +1,5 @@
0
 == 0.8.0 Dodgy Dentist release
0
+ * Allow disabling signal handling in Server with :signals => false
0
  * Make Server.new arguments more flexible, can now specify any of host, port, app or hash options.
0
  * Add --backend option to specified which backend to use, closes #55
0
  * Serve static file only on GET and HEAD requests in Rails adapter, fixes #58
...
14
15
16
17
 
18
19
20
21
 
22
23
24
 
25
26
27
...
44
45
46
47
 
 
48
49
50
...
115
116
117
 
 
118
119
120
121
...
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
198
199
200
201
 
 
 
 
202
203
204
...
14
15
16
 
17
18
19
20
 
21
22
 
 
23
24
25
26
...
43
44
45
 
46
47
48
49
50
...
115
116
117
118
119
120
121
122
123
...
132
133
134
 
 
 
135
136
137
 
 
138
139
140
...
195
196
197
 
198
199
200
201
202
203
204
0
@@ -14,14 +14,13 @@
0
   # as the first argument. Eg.: /tmp/thin.sock. If the first argument contains a <tt>/</tt>
0
   # it will be assumed to be a UNIX socket.
0
   #
0
- # Thin::Server.start('/tmp/thin.sock', nil, app)
0
+ # Thin::Server.start('/tmp/thin.sock', , app)
0
   #
0
   # == Using a custom backend
0
   # You can implement your own way to connect the server to its client by creating your
0
- # own Backend class and pass it as the first argument.
0
+ # own Backend class and pass it as the :backend option.
0
   #
0
- # backend = Thin::Backends::MyFancyBackend.new('galaxy://faraway:1345')
0
- # Thin::Server.start(backend, nil, app)
0
+ # Thin::Server.start('galaxy://faraway', 1345, app, :backend => Thin::Backends::MyFancyBackend)
0
   #
0
   # == Rack application (+app+)
0
   # All requests will be processed through +app+ that must be a valid Rack adapter.
0
@@ -44,7 +43,8 @@
0
   # == Controlling with signals
0
   # * QUIT: Gracefull shutdown (see Server#stop)
0
   # * INT and TERM: Force shutdown (see Server#stop!)
0
- #
0
+ # Disable signals by passing <tt>:signals => false</tt>
0
+ #
0
   class Server
0
     include Logging
0
     include Daemonizable
0
@@ -115,6 +115,8 @@
0
       
0
       # If in debug mode, wrap in logger adapter
0
       @app = Rack::CommonLogger.new(@app) if Logging.debug?
0
+
0
+ setup_signals unless options[:signals].class == FalseClass
0
     end
0
     
0
     # Lil' shortcut to turn this:
0
0
@@ -130,14 +132,9 @@
0
     end
0
         
0
     # Start the server and listen for connections.
0
- # Also register signals:
0
- # * INT calls +stop+ to shutdown gracefully.
0
- # * TERM calls <tt>stop!</tt> to force shutdown.
0
     def start
0
       raise ArgumentError, 'app required' unless @app
0
       
0
- setup_signals
0
-
0
       log ">> Thin web server (v#{VERSION::STRING} codename #{VERSION::CODENAME})"
0
       debug ">> Debugging ON"
0
       trace ">> Tracing ON"
0
@@ -198,7 +195,10 @@
0
       @backend.running?
0
     end
0
     
0
- protected
0
+ protected
0
+ # Register signals:
0
+ # * INT calls +stop+ to shutdown gracefully.
0
+ # * TERM calls <tt>stop!</tt> to force shutdown.
0
       def setup_signals
0
         trap('QUIT') { stop } unless Thin.win?
0
         trap('INT') { stop! }
...
79
80
81
82
 
 
 
 
 
 
83
...
79
80
81
 
82
83
84
85
86
87
88
0
@@ -79,6 +79,11 @@
0
     server.host.should_not be_nil
0
     server.app.should == app
0
     server.backend.should be_kind_of(Thin::Backends::SwiftiplyClient)
0
- end
0
+ end
0
+
0
+ it "should not register signals w/ :signals => false" do
0
+ Server.should_not_receive(:setup_signals)
0
+ Server.new(:signals => false)
0
+ end
0
 end

Comments

    No one has commented yet.