Class | Thin::Server |
In: |
lib/thin/server.rb
|
Parent: | Object |
The utterly famous Thin HTTP server. It listens for incoming requests through a given backend and forwards all requests to app.
Create a new TCP server 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 passing it as the :backend option.
Thin::Server.start('galaxy://faraway', 1345, app, :backend => Thin::Backends::MyFancyBackend)
All requests will be processed through app, which 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
Signals are processed at one second intervals. 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 | = | 100 |
app | [RW] | Application (Rack adapter) called with the request that produces the response. |
backend | [RW] | Backend handling the connections to the clients. |
tag | [RW] | A tag that will show in the process listing |
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.