root/tags/rel_1-0-1/README

Revision 420, 2.8 kB (checked in by zedshaw, 2 years ago)

Updated README with latest information and referred to mongrel site.

Line 
1 = Mongrel:  Simple Fast Mostly Ruby Web Server
2
3 Mongrel is a small library that provides a very fast HTTP 1.1 server for Ruby
4 web applications.  It is not particular to any framework, and is intended to
5 be just enough to get a web application running behind a more complete and robust
6 web server.
7
8 What makes Mongrel so fast is the careful use of a C extension to provide fast
9 HTTP 1.1 protocol parsing and fast URI lookup.  This combination makes the server
10 scream without too many portability issues.
11
12 You can view http://mongrel.rubyforge.org for more information.
13
14 == Quick Start
15
16 After you've installed (either with gem install mongrel or via source) you should
17 have the mongrel_rails command available in your PATH.  Then you just do the following:
18
19  > cd myrailsapp
20  > mongrel_rails start
21
22 This will start it in the foreground so you can play with it.  It runs your application
23 in production mode.  To get help do:
24
25  > mongrel_rails start -h
26
27 Finally, you can then start in background mode (probably won't work in win32):
28
29  > mongrel_rails start -d
30
31 And you can stop it whenever you like with:
32
33  > mongrel_rails stop
34
35 All of which should be done from your application's directory.  It writes the
36 PID of the process you ran into log/mongrel.pid.
37
38 There are also many more new options for configuring the rails runner including
39 changing to a different directory, adding more MIME types, and setting processor
40 threads and timeouts.
41
42
43 == Install
44
45 It doesn't explicitly require Camping, but if you want to run the examples/camping/
46 examples then you'll need to install Camping 1.2 at least (and redcloth I think). 
47 These are all available from RubyGems.
48
49 The library consists of a C extension so you'll need a C compiler or at least a friend
50 who can build it for you.
51
52 Finally, the source includes a setup.rb for those who hate RubyGems.
53
54 == Usage
55
56 The examples/simpletest.rb file has the following code as the simplest
57 example:
58
59  require 'mongrel'
60
61  class SimpleHandler < Mongrel::HttpHandler
62     def process(request, response)
63       response.start(200) do |head,out|
64         head["Content-Type"] = "text/plain"
65         out.write("hello!\n")
66       end
67     end
68  end
69
70  h = Mongrel::HttpServer.new("0.0.0.0", "3000")
71  h.register("/test", SimpleHandler.new)
72  h.register("/files", Mongrel::DirHandler.new("."))
73  h.run.join
74
75 If you run this and access port 3000 with a browser it will say
76 "hello!".  If you access it with any url other than "/test" it will
77 give a simple 404.  Check out the Mongrel::Error404Handler for a
78 basic way to give a more complex 404 message.
79
80 This also shows the DirHandler with directory listings.  This is still
81 rough but it should work for basic hosting.  *File extension to mime
82 type mapping is missing though.*
83
84 == Contact
85
86 E-mail zedshaw at zedshaw.com and I'll help.  Comments about the API are welcome.
Note: See TracBrowser for help on using the browser.