Class | Thin::Server |
In: |
lib/thin/server.rb
|
Parent: | Object |
The uterly famous Thin HTTP server. It listen for incoming request through a given backend and forward all request to app.
Create a new TCP server on bound to host:port by specifiying host and port as the first 2 arguments.
Thin::Server.start('0.0.0.0', 3000, app)
Create a new UNIX domain socket bound to socket file by specifiying a filename as the first argument. Eg.: /tmp/thin.sock. If the first argument contains a / it will be assumed to be a UNIX socket.
Thin::Server.start('/tmp/thin.sock', app)
You can implement your own way to connect the server to its client by creating your own Backend class and pass it as the :backend option.
Thin::Server.start('galaxy://faraway', 1345, app, :backend => Thin::Backends::MyFancyBackend)
All requests will be processed through app that must be a valid Rack adapter. A valid Rack adapter (application) must respond to call(env#Hash) and return an array of [status, headers, body].
If a block is passed, a Rack::Builder instance will be passed to build the app. So you can do cool stuff like this:
Thin::Server.start('0.0.0.0', 3000) do use Rack::CommonLogger use Rack::ShowExceptions map "/lobster" do use Rack::Lint run Rack::Lobster.new end end
Disable signals by passing :signals => false
DEFAULT_TIMEOUT | = | 30 | Default values | |
DEFAULT_HOST | = | '0.0.0.0' | ||
DEFAULT_PORT | = | 3000 | ||
DEFAULT_MAXIMUM_CONNECTIONS | = | 1024 | ||
DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS | = | 512 |
app | [RW] | Application (Rack adapter) called with the request that produces the response. |
backend | [RW] | Backend handling the connections to the clients. |
The process might need to have superuser privilege to configure server with optimal options.
Return true if the server is running and ready to receive requests. Note that the server might still be running and return false when shuting down and waiting for active connections to complete.
Stops the server closing all current connections right away. This doesn‘t wait for connection to finish their work and send data. All current requests will be dropped.
Taken from Mongrel cgi_multipart_eof_fix Ruby 1.8.5 has a security bug in cgi.rb, we need to patch it.