Skip to content

Commit

Permalink
Update README, HACKING, and version number.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.macosforge.org/repository/ruby/ControlTower/trunk@4529 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information
jballanc committed Sep 20, 2010
1 parent e10f4bc commit 637437b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 64 deletions.
65 changes: 14 additions & 51 deletions HACKING.rdoc
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
== Hacking Control Tower

Control Tower is still in very early development. It is being developed as part
of the MacRuby project, so be sure to familiarize yourself with MacRuby's
Control Tower is still a very young project. It is being developed as part of
the MacRuby project, so be sure to familiarize yourself with MacRuby's
HACKING.rdoc, as all guidelines there apply here as well. If you have any ideas
or suggestions for improvements, please communicate them with the MacRuby
developer's list at <[email protected]>. You can also find more
information at the MacRuby website (http://www.macruby.org/).


== CAUTION! AVERTISSEMENT! VOORZICHTIG! 注意!
=== CAUTION! AVERTISSEMENT! VOORZICHTIG! 注意!

DO NOT EDIT http11_parser.c! THIS FILE CONTAINS MACHINE GENERATED CODE.
N'EDITEZ PAS http11_parser.c! Ce fichier a été généré automatiquement.
Expand All @@ -20,55 +20,18 @@ Ragel (not included). It would also be acceptable to replace the parser all at
once, but editing it is not likely to ever be a good idea.


== Sample Code
=== Project Structure

There are two samples that you can run to explore ControlTower's behavior on GET
and POST requests located in the 'sample' directory. To use these samples, first
build and install the Control Tower gem:
The three components of ControlTower are:

> rake gem
> sudo macgem install pkg/control_tower-0.1-universal-darwin-10.gem
1. The Mongrel parser. The Ragel-generated C file is wrapped by an objective C
class and the whole thing is collected as an extension in ext/CTParser.

Then, to try a GET request, start the 'simple_hello.ru' rack-up config like so:

> control_tower -R sample/simple_hello.ru

and test it with a utility such as curl like so:

> curl http://localhost:8080/

This should reply with a very traditional string and a read-out of the rack
environment generated by your request. To try a POST request, start the
'file_upload.ru' config as above, then use curl (or similar tool) to send a post
with some file content like so:

> curl -F "[email protected]" http://localhost:8080/

This command tells curl to send the file as a form parameter, and the reply
should contain the content of the rack 'params' variable constructed from this
parameter. In particular, when the parameter is named 'file', the
'file_upload.ru' sample will return the contents of the file.


== Debugging

=== Environment variables

Currently, there is only one environment variable specifically for debugging
Control Tower:

* CT_DEBUG: This will turn on debug logging until we get a better logger.


== Known Issues

* Error compiling Regular Expression in Rack::Request
Workaround: Modify line 150 in rack/request.rb like so
- form_vars.sub!(/\0\z/, '')
+ form_vars.slice!(-1) if form_vars[-1] == "\0"

* Problem with Sinatra > 1.0 using Rack.release
Workaround: Modify line 39 in sinatra/base.rb like so
- if Rack.release < '1.1'
+ if Rack.version < '1.1'
2. The GCD based socket handling code. This is located in rack_socket.rb.
Primarily, the while loop located in the #open method on RackSocket. After
each connection is made, the connection is handed off to the GCD queue
(either serial or concurrent) for processing.

3. Interaction with the Rack app is coordinated by the Server object in
server.rb. Actually, the Server object handles the options hash and
coordinates opening and closing of the socket as well.
39 changes: 28 additions & 11 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
== Control Tower
Control Tower is a web application server for Rack-based MacRuby applications based on Apple's Grand Central Dispatch libraries.
== ControlTower

ControlTower is a web application server for Rack-based MacRuby applications
based on Apple's Grand Central Dispatch libraries.

It is composed of three major components: A Grand Central Dispatch based
networking layer, the Mongrel HTTP parser, and a Rack web application interface.

It is composed of three major components: A Grand Central Dispatch based networking layer, the Mongrel HTTP parser, and Rack web
application interface. It is currently very much a work in progress!

=== Installation
From the root directory of the project, run:

ControlTower can be installed as a gem using the `macgem` command. To build and
install from source, go to the root directory of the project and run:

$ rake package
$ sudo macgem install pkg/control_tower-0.1-universal-darwin-10.gem
$ sudo macgem install pkg/control_tower-1.0-universal-darwin-10.gem


=== Usage

There are currently only 4 supported command line options:

* -R <rackup_config.ru> : Where you specify the Rackup config file to run
* -h <hostname> : Hostname for the server (Control Tower will only respond to requests to this host)
* -p <port> : Port # for the server
* -c : Use this to enable serving requests to a GCD concurrent queue
* -R <config.ru> : Where you specify the Rack-up config to run
* -a <host> : Address to bind server to (default: 0.0.0.0)
* -p <port> : Port on which to run the server (default: 3000)
* -c : Enable serving requests on a concurrent GCD queue


=== Sample

There are a collection of Rack-up configs located in the "sample" directory that
demonstrate some features of ControlTower and MacRuby. See the README in that
directory for more information.


=== License
All the files in this distribution are covered under the Ruby's license (see the file COPYING).

All the files in this distribution are covered under the Ruby's license (see the
file COPYING).
3 changes: 1 addition & 2 deletions ext/CTParser/CTParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
#include "http11_parser.h"
#import <Foundation/Foundation.h>

// TODO - We should grab this from a plist somewhere...
#define SERVER_SOFTWARE @"Control Tower v0.1"
#define SERVER_SOFTWARE @"Control Tower v1.0"

@interface CTParser : NSObject
{
Expand Down
3 changes: 3 additions & 0 deletions sample/example_content.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is a file with some content to demonstrate ControlTower's X-Sendfile functionality.

See the README for more info.

0 comments on commit 637437b

Please sign in to comment.