Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

make example easily runnable

  • Loading branch information...
commit 852bbca7b4b31e296e05a5aee59668264b5a69c3 1 parent 6926051
Igor Wiedler authored December 28, 2011
14  README.md
Source Rendered
@@ -58,8 +58,18 @@ while (true) {
58 58
 }
59 59
 ```
60 60
 
61  
-    $ php example/hello.php
62  
-    $ curl http://localhost:6767/handlertest
  61
+Example
  62
+-------
  63
+
  64
+To run the example, run the following commands:
  65
+
  66
+    $ cd example
  67
+    $ m2sh load
  68
+    $ m2sh start
  69
+    # in a separate shell
  70
+    $ php hello.php
  71
+    # in a separate shell or browser
  72
+    $ curl http://localhost:6767/hello
63 73
 
64 74
 Tests
65 75
 -----
3  example/.gitignore
... ...
@@ -0,0 +1,3 @@
  1
+config.sqlite
  2
+logs/*
  3
+run/*
4  example/hello.php
@@ -2,6 +2,8 @@
2 2
 
3 3
 use Mongrel2\Connection;
4 4
 
  5
+require __DIR__.'/../vendor/.composer/autoload.php';
  6
+
5 7
 $sender_id = "82209006-86FF-4982-B5EA-D1E29E55D481";
6 8
 $conn = new Connection($sender_id, "tcp://127.0.0.1:9997", "tcp://127.0.0.1:9996");
7 9
 
@@ -12,5 +14,5 @@
12 14
         continue;
13 15
     }
14 16
 
15  
-    $this->conn->reply_http($req, 'Hello World');
  17
+    $conn->reply_http($req, 'Hello World');
16 18
 }
0  example/logs/.gitkeep
No changes.
21  example/mongrel2.conf
... ...
@@ -0,0 +1,21 @@
  1
+hello_handler = Handler(
  2
+    send_spec='tcp://*:9997', 
  3
+    send_ident='ab206881-6f49-4276-9db1-1676bfae18b0',
  4
+    recv_spec='tcp://*:9996', recv_ident=''
  5
+)
  6
+
  7
+main = Server(
  8
+    uuid="9e71cabf-6afb-4ee1-b550-7972245f7e0a",
  9
+    access_log="/logs/access.log",
  10
+    error_log="/logs/error.log",
  11
+    chroot="./",
  12
+    default_host="localhost",
  13
+    name="example",
  14
+    pid_file="/run/mongre2.pid",
  15
+    port=6767,
  16
+    hosts = [
  17
+        Host(name="localhost", routes={'/hello':hello_handler})
  18
+    ]
  19
+)
  20
+
  21
+servers = [main]
0  example/run/.gitkeep
No changes.

0 notes on commit 852bbca

Please sign in to comment.
Something went wrong with that request. Please try again.