From 4b20f5cd08bc69d95d81d47bff943f775c1a983e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 7 Sep 2013 20:26:26 +0200 Subject: Convert the chunked hello world example to a release --- examples/chunked_hello_world/Makefile | 14 ++++++++++ examples/chunked_hello_world/README.md | 30 ++++++++++++---------- examples/chunked_hello_world/rebar.config | 4 --- examples/chunked_hello_world/relx.config | 2 ++ .../src/chunked_hello_world.erl | 15 ----------- examples/chunked_hello_world/start.sh | 3 --- 6 files changed, 33 insertions(+), 35 deletions(-) create mode 100644 examples/chunked_hello_world/Makefile delete mode 100644 examples/chunked_hello_world/rebar.config create mode 100644 examples/chunked_hello_world/relx.config delete mode 100644 examples/chunked_hello_world/src/chunked_hello_world.erl delete mode 100755 examples/chunked_hello_world/start.sh diff --git a/examples/chunked_hello_world/Makefile b/examples/chunked_hello_world/Makefile new file mode 100644 index 0000000..e50baa8 --- /dev/null +++ b/examples/chunked_hello_world/Makefile @@ -0,0 +1,14 @@ +PROJECT = chunked_hello_world + +DEPS = cowboy +dep_cowboy = pkg://cowboy master + +.PHONY: release clean-release + +release: clean-release all + relx + +clean-release: + rm -rf _rel + +include ../../erlang.mk diff --git a/examples/chunked_hello_world/README.md b/examples/chunked_hello_world/README.md index be8f046..7e7cf21 100644 --- a/examples/chunked_hello_world/README.md +++ b/examples/chunked_hello_world/README.md @@ -1,24 +1,28 @@ -Cowboy Chunked Hello World -========================== +Chunked hello world example +=========================== -To compile this example you need rebar in your PATH. +To try this example, you need GNU `make`, `git` and +[relx](https://github.com/erlware/relx) in your PATH. -Type the following command: -``` -$ rebar get-deps compile -``` +To build the example, run the following command: -You can then start the Erlang node with the following command: +``` bash +$ make ``` -./start.sh + +To start the release in the foreground: + +``` bash +$ ./_rel/bin/chunked_hello_world_example console ``` -Then run the given command or point your browser to the indicated URL. +Then point your browser at [http://localhost:8080](http://localhost:8080), +or use `curl` to see the chunks arriving one at a time every second. -Example -------- +Example output +-------------- -```bash +``` bash $ time curl -i http://localhost:8080 HTTP/1.1 200 OK transfer-encoding: chunked diff --git a/examples/chunked_hello_world/rebar.config b/examples/chunked_hello_world/rebar.config deleted file mode 100644 index 6ad3062..0000000 --- a/examples/chunked_hello_world/rebar.config +++ /dev/null @@ -1,4 +0,0 @@ -{deps, [ - {cowboy, ".*", - {git, "git://github.com/extend/cowboy.git", "master"}} -]}. diff --git a/examples/chunked_hello_world/relx.config b/examples/chunked_hello_world/relx.config new file mode 100644 index 0000000..88e7b52 --- /dev/null +++ b/examples/chunked_hello_world/relx.config @@ -0,0 +1,2 @@ +{release, {chunked_hello_world_example, "1"}, [chunked_hello_world]}. +{extended_start_script, true}. diff --git a/examples/chunked_hello_world/src/chunked_hello_world.erl b/examples/chunked_hello_world/src/chunked_hello_world.erl deleted file mode 100644 index d75511f..0000000 --- a/examples/chunked_hello_world/src/chunked_hello_world.erl +++ /dev/null @@ -1,15 +0,0 @@ -%% Feel free to use, reuse and abuse the code in this file. - --module(chunked_hello_world). - -%% API. --export([start/0]). - -%% API. - -start() -> - ok = application:start(crypto), - ok = application:start(cowlib), - ok = application:start(ranch), - ok = application:start(cowboy), - ok = application:start(chunked_hello_world). diff --git a/examples/chunked_hello_world/start.sh b/examples/chunked_hello_world/start.sh deleted file mode 100755 index 0f157ad..0000000 --- a/examples/chunked_hello_world/start.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -erl -pa ebin deps/*/ebin -s chunked_hello_world \ - -eval "io:format(\"Run: curl -i http://localhost:8080~n\")." -- cgit v1.2.3