Browse Source

Merge branch 'phoenix-orm_elixir-cowboy' of https://github.com/waiteb3/FrameworkBenchmarks into 1633

Conflicts:
	frameworks/Elixir/phoenix/benchmark_config.json
msmith-techempower 10 years ago
parent
commit
92f82ccdab
46 changed files with 384 additions and 220 deletions
  1. 1 0
      .travis.yml
  2. 5 0
      frameworks/Elixir/cowboy/.gitignore
  3. 1 0
      frameworks/Elixir/cowboy/README.md
  4. 24 0
      frameworks/Elixir/cowboy/benchmark_config.json
  5. 7 0
      frameworks/Elixir/cowboy/config/config.exs
  6. 3 0
      frameworks/Elixir/cowboy/install.sh
  7. 56 0
      frameworks/Elixir/cowboy/lib/hello.ex
  8. 20 0
      frameworks/Elixir/cowboy/mix.exs
  9. 13 0
      frameworks/Elixir/cowboy/setup.sh
  10. 3 2
      frameworks/Elixir/phoenix/.gitignore
  11. 5 1
      frameworks/Elixir/phoenix/benchmark_config.json
  12. 4 3
      frameworks/Elixir/phoenix/config/config.exs
  13. 24 4
      frameworks/Elixir/phoenix/config/dev.exs
  14. 12 3
      frameworks/Elixir/phoenix/config/prod.exs
  15. 7 0
      frameworks/Elixir/phoenix/config/prod.secret.exs
  16. 0 7
      frameworks/Elixir/phoenix/config/test.exs
  17. 2 1
      frameworks/Elixir/phoenix/lib/hello.ex
  18. 8 6
      frameworks/Elixir/phoenix/lib/hello/endpoint.ex
  19. 3 0
      frameworks/Elixir/phoenix/lib/hello/repo.ex
  20. 17 10
      frameworks/Elixir/phoenix/mix.exs
  21. 6 6
      frameworks/Elixir/phoenix/setup.sh
  22. 0 7
      frameworks/Elixir/phoenix/test/hello_test.exs
  23. 0 1
      frameworks/Elixir/phoenix/test/test_helper.exs
  24. 26 13
      frameworks/Elixir/phoenix/web/controllers/page_controller.ex
  25. 15 0
      frameworks/Elixir/phoenix/web/models/fortune.ex
  26. 0 11
      frameworks/Elixir/phoenix/web/models/repo.exs
  27. 15 0
      frameworks/Elixir/phoenix/web/models/world.ex
  28. 0 7
      frameworks/Elixir/phoenix/web/models/world.exs
  29. 5 5
      frameworks/Elixir/phoenix/web/router.ex
  30. 1 31
      frameworks/Elixir/phoenix/web/templates/layout/application.html.eex
  31. 0 1
      frameworks/Elixir/phoenix/web/templates/page/error.html.eex
  32. 1 0
      frameworks/Elixir/phoenix/web/templates/page/fortunes.html.eex
  33. 0 34
      frameworks/Elixir/phoenix/web/templates/page/index.html.eex
  34. 0 1
      frameworks/Elixir/phoenix/web/templates/page/not_found.html.eex
  35. 0 17
      frameworks/Elixir/phoenix/web/view.ex
  36. 4 3
      frameworks/Elixir/phoenix/web/views/error_view.ex
  37. 1 1
      frameworks/Elixir/phoenix/web/views/layout_view.ex
  38. 1 1
      frameworks/Elixir/phoenix/web/views/page_view.ex
  39. 73 0
      frameworks/Elixir/phoenix/web/web.ex
  40. 1 1
      frameworks/Erlang/cowboy/install.sh
  41. 2 3
      frameworks/Erlang/cowboy/setup.sh
  42. 1 1
      frameworks/Erlang/elli/install.sh
  43. 2 3
      frameworks/Erlang/elli/setup.sh
  44. 8 10
      toolset/setup/linux/languages/elixir.sh
  45. 7 11
      toolset/setup/linux/languages/erlang.sh
  46. 0 15
      toolset/setup/linux/systools/rebar.sh

+ 1 - 0
.travis.yml

@@ -43,6 +43,7 @@ env:
     - "TESTDIR=Dart/dart-start"
     - "TESTDIR=Dart/dart-stream"
     - "TESTDIR=Elixir/phoenix"
+    - "TESTDIR=Elixir/cowboy"
     - "TESTDIR=Erlang/cowboy"
     - "TESTDIR=Erlang/elli"
     - "TESTDIR=Go/beego"

+ 5 - 0
frameworks/Elixir/cowboy/.gitignore

@@ -0,0 +1,5 @@
+_build/
+rel/
+deps/
+erl_crash.dump
+*.ez

+ 1 - 0
frameworks/Elixir/cowboy/README.md

@@ -0,0 +1 @@
+# Elixir-cowboy

+ 24 - 0
frameworks/Elixir/cowboy/benchmark_config.json

@@ -0,0 +1,24 @@
+{
+    "framework": "elixir-cowboy",
+    "tests": [{
+        "default": {
+            "setup_file": "setup",
+            "json_url": "/json",
+            "plaintext_url": "/plaintext",
+            "port": 8080,
+            "approach": "Realistic",
+            "classification": "Platform",
+            "database": "None",
+            "framework": "cowboy",
+            "language": "elixir",
+            "orm": "raw",
+            "platform": "Erlang/OTP",
+            "webserver": "cowboy",
+            "os": "Linux",
+            "database_os": "Linux",
+            "display_name": "elixir-cowboy",
+            "notes": "",
+            "versus": ""
+        }
+    }]
+}

+ 7 - 0
frameworks/Elixir/cowboy/config/config.exs

@@ -0,0 +1,7 @@
+use Mix.Config
+
+config :mysql,
+  username: "benchmarkdbuser",
+  password: "benchmarkdbpass",
+  database: "hello_world",
+  hostname: "localhost"

+ 3 - 0
frameworks/Elixir/cowboy/install.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+fw_depends elixir

+ 56 - 0
frameworks/Elixir/cowboy/lib/hello.ex

@@ -0,0 +1,56 @@
+defmodule Hello do
+
+  def start(_type, _args) do
+    dispatch = :cowboy_router.compile([
+
+      { :_,
+        [
+          {"/json", JsonHandler, []},
+          {"/plaintext", PlaintextHandler, []}
+      ]}
+    ])
+    { :ok, _ } = :cowboy.start_http(:http,
+                                    5000,
+                                   [{:port, 8080}],
+                                   [{ :env, [{:dispatch, dispatch}]}]
+                                   )
+  end
+end
+
+defmodule JsonHandler do
+  def init(_type, req, []) do
+    {:ok, req, :no_state}
+  end
+
+  def handle(request, state) do
+    Poison.encode!(%{message: "Hello, World!"})
+    { :ok, reply } = :cowboy_req.reply(200,
+      [{"content-type", "application/json"}],
+      Poison.encode!(%{:message => "Hello, World!"}),
+      request)
+    { :ok, reply, state }
+  end
+
+  def terminate(reason, request, state) do
+    :ok
+  end
+end
+
+defmodule PlaintextHandler do
+  def init(_type, req, []) do
+    {:ok, req, :no_state}
+  end
+
+  def handle(request, state) do
+    Poison.encode!(%{message: "Hello, World!"})
+    { :ok, reply } = :cowboy_req.reply(200,
+      [{"content-type", "text/plain"}],
+      "Hello, World!",
+      request)
+    { :ok, reply, state }
+  end
+
+  def terminate(reason, request, state) do
+    :ok
+  end
+end

+ 20 - 0
frameworks/Elixir/cowboy/mix.exs

@@ -0,0 +1,20 @@
+defmodule Hello.Mixfile do
+  use Mix.Project
+
+  def project do
+    [app: :hello,
+     version: "0.0.1",
+     elixir: "~> 1.0",
+     deps: deps]
+  end
+
+  def application do
+    [mod: {Hello, []},
+     applications: [:cowboy, :ranch, :poison]]
+  end
+
+  defp deps do
+    [{:cowboy, "~> 1.0"},
+     {:poison, "~> 1.4.0"}]
+  end
+end

+ 13 - 0
frameworks/Elixir/cowboy/setup.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+
+source $IROOT/elixir.installed
+
+rm -rf _build deps rel
+
+MIX_ENV=prod
+export MIX_ENV
+mix local.hex --force
+mix deps.get --force
+mix compile --force
+
+elixir --detached --no-halt -S mix

+ 3 - 2
frameworks/Elixir/phoenix/.gitignore

@@ -1,4 +1,5 @@
-/_build
-/deps
+_build/
+rel/
+deps/
 erl_crash.dump
 *.ez

+ 5 - 1
frameworks/Elixir/phoenix/benchmark_config.json

@@ -4,6 +4,10 @@
         "default": {
             "setup_file": "setup",
             "json_url": "/json",
+            "db_url": "/db",
+            "query_url": "/queries?queries=",
+            "fortune_url": "/fortune",
+            "update_url": "/update?queries=",
             "plaintext_url": "/plaintext",
             "port": 8080,
             "approach": "Realistic",
@@ -16,7 +20,7 @@
             "webserver": "cowboy",
             "os": "Linux",
             "database_os": "Linux",
-            "display_name": "phoenix",
+            "display_name": "Phoenix",
             "notes": "",
             "versus": ""
         }

+ 4 - 3
frameworks/Elixir/phoenix/config/config.exs

@@ -8,10 +8,11 @@ use Mix.Config
 # Configures the endpoint
 config :hello, Hello.Endpoint,
   url: [host: "localhost"],
-  secret_key_base: "Z18ZjzZslFpKd8HB41IljqMavPiOKVF9y1DIQ+S2Ytg7Op0EIauwJgd7mtRStssx",
+  http: [port: 8080],
+  root: Path.expand(__DIR__),
   debug_errors: false,
-  pubsub: [adapter: Phoenix.PubSub.PG2]
-
+  secret_key_base: "Z18ZjzZslFpKd8HB41IljqMavPiOKVF9y1DIQ+S2Ytg7Op0EIauwJgd7mtRStssx",
+  pubsub: [name: Hello.PubSub, adapter: Phoenix.PubSub.PG2]
 
 # Configures Elixir's Logger
 config :logger, :console,

+ 24 - 4
frameworks/Elixir/phoenix/config/dev.exs

@@ -1,13 +1,33 @@
 use Mix.Config
 
+# For development, we disable any cache and enable
+# debugging and code reloading.
+#
+# The watchers configuration can be used to run external
+# watchers to your application. For example, we use it
+# with brunch.io to recompile .js and .css sources.
 config :hello, Hello.Endpoint,
-  url: [host: "localhost", port: 8080],
-  http: [port: System.get_env("PORT") || 8080],
+  http: [port: 8080],
   debug_errors: true,
+  code_reloader: true,
   cache_static_lookup: false
 
-# Enables code reloading for development
-config :phoenix, :code_reloader, true
+# Watch static and templates for browser reloading.
+config :hello, Hello.Endpoint,
+  live_reload: [
+    patterns: [
+      ~r{priv/static/.*(js|css|png|jpeg|jpg|gif)$},
+      ~r{web/views/.*(ex)$},
+      ~r{web/templates/.*(eex)$}
+    ]
+  ]
+
+config :hello, Hello.Repo,
+  adapter: Ecto.Adapters.MySQL,
+  username: "benchmarkdbuser",
+  password: "benchmarkdbpass",
+  database: "hello_world",
+  hostname: "localhost"
 
 # Do not include metadata nor timestamps in development logs
 config :logger, :console, format: "[$level] $message\n"

+ 12 - 3
frameworks/Elixir/phoenix/config/prod.exs

@@ -1,10 +1,17 @@
 use Mix.Config
 
 config :hello, Hello.Endpoint,
-  url: [host: "localhost", port: 8080],
+  url: [host: "0.0.0.0"],
   http: [port: 8080],
-  secret_key_base: "Z18ZjzZslFpKd8HB41IljqMavPiOKVF9y1DIQ+S2Ytg7Op0EIauwJgd7mtRStssx",
-  cache_static_lookup: false
+  cache_static_lookup: false,
+  server: true
+
+config :hello, Hello.Repo,
+  adapter: Ecto.Adapters.MySQL,
+  username: "benchmarkdbuser",
+  password: "benchmarkdbpass",
+  database: "hello_world",
+  hostname: "localhost"
 
 # ## SSL Support
 #
@@ -36,3 +43,5 @@ config :logger, level: :info
 #
 #     config :hello, Hello.Endpoint, server: true
 #
+
+import_config "prod.secret.exs"

+ 7 - 0
frameworks/Elixir/phoenix/config/prod.secret.exs

@@ -0,0 +1,7 @@
+use Mix.Config
+
+# In this file, we keep production configuration that
+# you likely want to automate and keep it away from
+# your version control system.
+config :hello, Hello.Endpoint,
+  secret_key_base: "Z18ZjzZslFpKd8HB41IljqMavPiOKVF9y1DIQ+S2Ytg7Op0EIauwJgd7mtRStssx"

+ 0 - 7
frameworks/Elixir/phoenix/config/test.exs

@@ -1,7 +0,0 @@
-use Mix.Config
-
-config :hello, Hello.Endpoint,
-  http: [port: System.get_env("PORT") || 4001]
-
-# Print only warnings and errors during test
-config :logger, level: :warn

+ 2 - 1
frameworks/Elixir/phoenix/lib/hello.ex

@@ -10,8 +10,9 @@ defmodule Hello do
       # Start the endpoint when the application starts
       supervisor(Hello.Endpoint, []),
       # Here you could define other workers and supervisors as children
+      # Start the Ecto repository
+      worker(Hello.Repo, [])
       # worker(Hello.Worker, [arg1, arg2, arg3]),
-      # worker(Hello.Repo, [])
     ]
 
     # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html

+ 8 - 6
frameworks/Elixir/phoenix/lib/hello/endpoint.ex

@@ -3,14 +3,17 @@ defmodule Hello.Endpoint do
 
   # Serve at "/" the given assets from "priv/static" directory
   plug Plug.Static,
-    at: "/", from: :hello,
+    at: "/", from: :hello, gzip: false,
     only: ~w(css images js favicon.ico robots.txt)
 
-  plug Plug.Logger
-
   # Code reloading will only work if the :code_reloader key of
   # the :phoenix application is set to true in your config file.
-  plug Phoenix.CodeReloader
+  if code_reloading? do
+    plug Phoenix.LiveReloader
+    plug Phoenix.CodeReloader
+  end
+
+  plug Plug.Logger
 
   plug Plug.Parsers,
     parsers: [:urlencoded, :multipart, :json],
@@ -23,8 +26,7 @@ defmodule Hello.Endpoint do
   plug Plug.Session,
     store: :cookie,
     key: "_hello_key",
-    signing_salt: "DNlAnJ2o",
-    encryption_salt: "AOXxaZRq"
+    signing_salt: "DNlAnJ2o"
 
   plug :router, Hello.Router
 end

+ 3 - 0
frameworks/Elixir/phoenix/lib/hello/repo.ex

@@ -0,0 +1,3 @@
+defmodule Hello.Repo do
+    use Ecto.Repo, otp_app: :hello
+end

+ 17 - 10
frameworks/Elixir/phoenix/mix.exs

@@ -2,12 +2,14 @@ defmodule Hello.Mixfile do
   use Mix.Project
 
   def project do
-    [app: :hello,
-     version: "0.0.1",
-     elixir: "~> 1.0",
-     elixirc_paths: ["lib", "web"],
-     compilers: [:phoenix] ++ Mix.compilers,
-     deps: deps]
+   [app: :hello,
+    version: "0.0.1",
+    elixir: "~> 1.0",
+    elixirc_paths: elixirc_paths(Mix.env),
+    compilers: [:phoenix] ++ Mix.compilers,
+    build_embedded: Mix.env == :prod,
+    start_permanent: Mix.env == :prod,
+    deps: deps]
   end
 
   # Configuration for the OTP application
@@ -15,16 +17,21 @@ defmodule Hello.Mixfile do
   # Type `mix help compile.app` for more information
   def application do
     [mod: {Hello, []},
-     applications: [:phoenix, :cowboy, :logger, :postgrex, :ecto]]
+     applications: [:phoenix, :phoenix_ecto, :mariaex, :cowboy, :logger, :phoenix_html]]
   end
 
+  defp elixirc_paths(_), do: ["lib", "web"]
+
   # Specifies your project dependencies
   #
   # Type `mix help deps` for examples and options
   defp deps do
-    [{:phoenix, "~> 0.9.0"},
+    [{:phoenix, "~> 0.13.1"},
+     {:phoenix_ecto, "~> 0.4"},
+     {:mariaex, ">= 0.0.0"},
      {:cowboy, "~> 1.0"},
-     {:postgrex, "~> 0.6.0"},
-     {:ecto, "~> 0.2.5"}]
+     {:phoenix_html, "~> 1.0"},
+     {:phoenix_live_reload, "~> 0.4", only: :dev},
+     {:exrm, "~> 0.15.3"}]
   end
 end

+ 6 - 6
frameworks/Elixir/phoenix/setup.sh

@@ -2,14 +2,14 @@
 
 source $IROOT/elixir.installed
 
-sed -i 's|db_host: "localhost",|db_host: "${DBHOST}",|g' config/config.exs
+sed -i 's|hostname: "localhost"|hostname: "'${DBHOST}'"|g' config/prod.exs
 
-rm -rf _build deps
+rm -rf _build deps rel
 
+MIX_ENV=prod
+export MIX_ENV
 mix local.hex --force
-mix local.rebar --force
 mix deps.get --force
+mix compile --force
 
-MIX_ENV=prod mix compile.protocols --force
-MIX_ENV=prod elixir --detached -pa _build/$MIX_ENV/consolidated -S mix phoenix.server
-
+elixir --detached -S mix phoenix.server

+ 0 - 7
frameworks/Elixir/phoenix/test/hello_test.exs

@@ -1,7 +0,0 @@
-defmodule HelloTest do
-  use ExUnit.Case
-
-  test "the truth" do
-    assert 1 + 1 == 2
-  end
-end

+ 0 - 1
frameworks/Elixir/phoenix/test/test_helper.exs

@@ -1 +0,0 @@
-ExUnit.start

+ 26 - 13
frameworks/Elixir/phoenix/web/controllers/page_controller.ex

@@ -1,14 +1,14 @@
 defmodule Hello.PageController do
-  use Phoenix.Controller
+  use Hello.Web, :controller
+  alias Hello.World
+  alias Hello.Fortune
 
   plug :action
+  plug :scrub_params, "world" when action in [:create, :update]
+
 
   def index(conn, _params) do
-    json conn, %{
-      "TE Benchmarks\n" => "Started",
-      "DBHOST" => System.get_env("DBHOST"),
-      "DBPORT" => System.get_env("DBPORT"),
-    }
+    json conn, %{"TE Benchmarks\n" => "Started"}
   end
 
   # avoid namespace collision
@@ -17,22 +17,35 @@ defmodule Hello.PageController do
   end
 
   def db(conn, _params) do
-    :random.seed(:erlang.now)
-    id = :random.uniform(10000)
-    text conn, "TE Benchmarks\n"
+    json conn, Repo.get(World, :random.uniform(10000))
   end
 
   def queries(conn, _params) do
-    text conn, "TE Benchmarks\n"
+    q = case String.to_integer(_params["queries"]) do
+      x when x < 1    -> 1
+      x when x > 500  -> 500
+      x               -> x
+    end
+    json conn, Enum.map(1..q, fn _ -> Repo.get(World, :random.uniform(10000)) end)
   end
 
   def fortunes(conn, _params) do
-    text conn, "TE Benchmarks\n"
+    fortunes = List.insert_at(Repo.all(Fortune), 0, %Fortune{:id => 0, :message  => "Additional fortune added at request time."})
+    render conn, "fortunes.html", fortunes: Enum.sort(fortunes, fn f1, f2 -> f1.message < f2.message end)
   end
 
   def updates(conn, _params) do
-    text conn, "TE Benchmarks\n"
-  end
+    q = case String.to_integer(_params["queries"]) do
+      x when x < 1    -> 1
+      x when x > 500  -> 500
+      x               -> x
+    end
+    json conn, Enum.map(1..q, fn _ ->
+      w = Repo.get(World, :random.uniform(10000))
+      changeset = World.changeset(w, %{randomNumber: :random.uniform(10000)})
+      Repo.update(changeset)
+      w end)
+    end
 
   def plaintext(conn, _params) do
     text conn, "Hello, world!"

+ 15 - 0
frameworks/Elixir/phoenix/web/models/fortune.ex

@@ -0,0 +1,15 @@
+defmodule Hello.Fortune do
+  use Hello.Web, :model
+
+  schema "fortune" do
+    field :message, :string
+  end
+
+  @required_fields ~w(message)
+  @optional_fields ~w()
+
+  def changeset(model, params \\ nil) do
+    model
+    |> cast(params, @required_fields, @optional_fields)
+  end
+end

+ 0 - 11
frameworks/Elixir/phoenix/web/models/repo.exs

@@ -1,11 +0,0 @@
-defmodule Hello.Repo do
-  use Ecto.Repo, adapter: Ecto.Adapters.Postgres
-
-  def conf do
-    parse_url "ecto://username:password@host/database_name"
-  end
-
-  def priv do
-    app_dir(:hello, "priv/repo")
-  end
-end

+ 15 - 0
frameworks/Elixir/phoenix/web/models/world.ex

@@ -0,0 +1,15 @@
+defmodule Hello.World do
+  use Hello.Web, :model
+
+  schema "world" do
+    field :randomNumber, :integer
+  end
+
+  @required_fields ~w(randomNumber)
+  @optional_fields ~w()
+
+  def changeset(model, params \\ nil) do
+    model
+    |> cast(params, @required_fields, @optional_fields)
+  end
+end

+ 0 - 7
frameworks/Elixir/phoenix/web/models/world.exs

@@ -1,7 +0,0 @@
-defmodule Hello.User do
-  use Ecto.Model
-
-  schema "world" do
-    field :randomNumber, :integer
-  end
-end

+ 5 - 5
frameworks/Elixir/phoenix/web/router.ex

@@ -1,15 +1,15 @@
 defmodule Hello.Router do
-  use Phoenix.Router
+  use Hello.Web, :router
 
   pipeline :browser do
-    plug :accepts, ~w(html)
+    plug :accepts, ["html"]
     plug :fetch_session
     plug :fetch_flash
     plug :protect_from_forgery
   end
 
   pipeline :api do
-    plug :accepts, ~w(json)
+    plug :accepts, ["json"]
   end
 
   scope "/", Hello do
@@ -18,8 +18,8 @@ defmodule Hello.Router do
     get "/json", PageController, :_json
     get "/db", PageController, :db
     get "/queries", PageController, :queries
-    get "/fortunes", PageController, :fortunes
-    get "/updates", PageController, :updates
+    get "/fortune", PageController, :fortunes
+    get "/update", PageController, :updates
     get "/plaintext", PageController, :plaintext
     get "/", PageController, :index
   end

+ 1 - 31
frameworks/Elixir/phoenix/web/templates/layout/application.html.eex

@@ -1,31 +1 @@
-<!DOCTYPE html>
-<html lang="en">
-  <head>
-    <meta charset="utf-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <meta name="description" content="">
-    <meta name="author" content="">
-
-    <title>Hello Phoenix!</title>
-    <link rel="stylesheet" href="/css/phoenix.css">
-  </head>
-
-  <body>
-    <div class="container">
-      <div class="header">
-        <ul class="nav nav-pills pull-right">
-          <li><a href="http://www.phoenixframework.org/docs">Get Started</a></li>
-        </ul>
-        <span class="logo"></span>
-      </div>
-
-      <%= @inner %>
-
-      <div class="footer">
-        <p><a href="http://phoenixframework.org">phoenixframework.org</a></p>
-      </div>
-
-    </div> <!-- /container -->
-  </body>
-</html>
+<!DOCTYPE html><html lang="en"><head><title>Fortunes</title></head><body><%= @inner %></body></html>

+ 0 - 1
frameworks/Elixir/phoenix/web/templates/page/error.html.eex

@@ -1 +0,0 @@
-Something went wrong

+ 1 - 0
frameworks/Elixir/phoenix/web/templates/page/fortunes.html.eex

@@ -0,0 +1 @@
+<table><tr><th>id</th><th>message</th></tr><%= for f <- @fortunes do %><tr><td><%= f.id %></td><td><%= f.message %></td></tr><% end %></table>

+ 0 - 34
frameworks/Elixir/phoenix/web/templates/page/index.html.eex

@@ -1,34 +0,0 @@
-<div class="jumbotron">
-  <h2>Welcome to Phoenix!</h2>
-  <p class="lead">Phoenix is an Elixir Web Framework targeting full-featured, fault tolerant applications with realtime functionality.</p>
-</div>
-
-<div class="row marketing">
-  <div class="col-lg-6">
-    <h4>Resources</h4>
-    <ul>
-      <li>
-        <a href="http://hexdocs.pm/phoenix">Docs</a>
-      </li>
-      <li>
-        <a href="https://github.com/phoenixframework/phoenix">Source</a>
-      </li>
-    </ul>
-  </div>
-
-  <div class="col-lg-6">
-    <h4>Help</h4>
-    <ul>
-      <li>
-        <a href="https://github.com/phoenixframework/phoenix/issues?state=open">Issues</a>
-      </li>
-      <li>
-        <a href="irc://irc.freenode.net/elixir-lang">#elixir-lang on freenode IRC</a>
-      </li>
-      <li>
-        <a href="https://twitter.com/chris_mccord">@chris_mccord</a>
-      </li>
-    </ul>
-  </div>
-</div>
-

+ 0 - 1
frameworks/Elixir/phoenix/web/templates/page/not_found.html.eex

@@ -1 +0,0 @@
-The page you are looking for does not exist

+ 0 - 17
frameworks/Elixir/phoenix/web/view.ex

@@ -1,17 +0,0 @@
-defmodule Hello.View do
-  use Phoenix.View, root: "web/templates"
-
-  # The quoted expression returned by this block is applied
-  # to this module and all other views that use this module.
-  using do
-    quote do
-      # Import common functionality
-      import Hello.Router.Helpers
-
-      # Use Phoenix.HTML to import all HTML functions (forms, tags, etc)
-      use Phoenix.HTML
-    end
-  end
-
-  # Functions defined here are available to all other views/templates
-end

+ 4 - 3
frameworks/Elixir/phoenix/web/views/error_view.ex

@@ -1,5 +1,5 @@
 defmodule Hello.ErrorView do
-  use Hello.View
+  use Hello.Web, :view
 
   def render("404.html", _assigns) do
     "Page not found - 404"
@@ -9,8 +9,9 @@ defmodule Hello.ErrorView do
     "Server internal error - 500"
   end
 
-  # Render all other templates as 500
-  def render(_, assigns) do
+  # In case no render clause matches or no
+  # template is found, let's render it as 500
+  def template_not_found(_template, assigns) do
     render "500.html", assigns
   end
 end

+ 1 - 1
frameworks/Elixir/phoenix/web/views/layout_view.ex

@@ -1,3 +1,3 @@
 defmodule Hello.LayoutView do
-  use Hello.View
+  use Hello.Web, :view
 end

+ 1 - 1
frameworks/Elixir/phoenix/web/views/page_view.ex

@@ -1,3 +1,3 @@
 defmodule Hello.PageView do
-  use Hello.View
+  use Hello.Web, :view
 end

+ 73 - 0
frameworks/Elixir/phoenix/web/web.ex

@@ -0,0 +1,73 @@
+defmodule Hello.Web do
+  @moduledoc """
+  A module that keeps using definitions for controllers,
+  views and so on.
+
+  This can be used in your application as:
+
+      use Hello.Web, :controller
+      use Hello.Web, :view
+
+  Keep the definitions in this module short and clean,
+  mostly focused on imports, uses and aliases.
+  """
+
+  def model do
+    quote do
+      use Ecto.Model
+    end
+  end
+
+  def controller do
+    quote do
+      use Phoenix.Controller
+
+      # Alias the data repository and import query/model functions
+      alias Hello.Repo
+      import Ecto.Model
+      import Ecto.Query
+
+      # Import URL helpers from the router
+      import Hello.Router.Helpers
+    end
+  end
+
+  def view do
+    quote do
+      use Phoenix.View, root: "web/templates"
+
+      # Import convenience functions from controllers
+      import Phoenix.Controller, only: [get_csrf_token: 0, get_flash: 2, view_module: 1]
+
+      # Import URL helpers from the router
+      import Hello.Router.Helpers
+
+      # Import all HTML functions (forms, tags, etc)
+      use Phoenix.HTML
+    end
+  end
+
+  def router do
+    quote do
+      use Phoenix.Router
+    end
+  end
+
+
+  def channel do
+    quote do
+      use Phoenix.Channel
+      # Alias the data repository and import query/model functions
+      alias Hello.Repo
+      import Ecto.Model
+      import Ecto.Query, only: [from: 2]
+    end
+  end
+
+  @doc """
+  When used, dispatch to the appropriate controller/view/etc.
+  """
+  defmacro __using__(which) when is_atom(which) do
+    apply(__MODULE__, which, [])
+  end
+end

+ 1 - 1
frameworks/Erlang/cowboy/install.sh

@@ -1,3 +1,3 @@
 #!/bin/bash
 
-fw_depends erlang rebar
+fw_depends erlang

+ 2 - 3
frameworks/Erlang/cowboy/setup.sh

@@ -1,11 +1,10 @@
 #!/bin/bash
 
 source $IROOT/erlang.installed
-source $IROOT/rebar.installed
 
 sed -i 's|"benchmarkdbpass", ".*", 3306|"benchmarkdbpass", "'"${DBHOST}"'", 3306|g' src/hello_world_app.erl
 
 rm -rf deps/* ebin/*
-$REBAR_HOME/rebar get-deps
-$REBAR_HOME/rebar compile
+rebar get-deps
+rebar compile
 erl -pa ebin deps/*/ebin +sbwt very_long +swt very_low -s hello_world -noshell -detached

+ 1 - 1
frameworks/Erlang/elli/install.sh

@@ -1,3 +1,3 @@
 #!/bin/bash
 
-fw_depends erlang rebar
+fw_depends erlang

+ 2 - 3
frameworks/Erlang/elli/setup.sh

@@ -1,11 +1,10 @@
 #!/bin/bash
 
 source $IROOT/erlang.installed
-source $IROOT/rebar.installed
 
 sed -i 's|"benchmarkdbpass", ".*", 3306|"benchmarkdbpass", "'"${DBHOST}"'", 3306|g' src/elli_bench_sup.erl
 
 rm -rf deps/* ebin/*
-$REBAR_HOME/rebar get-deps
-$REBAR_HOME/rebar compile
+rebar get-deps
+rebar compile
 erl -pa ebin deps/*/ebin +sbwt very_long +swt very_low -s elli_bench -noshell -detached

+ 8 - 10
toolset/setup/linux/languages/elixir.sh

@@ -4,16 +4,14 @@ RETCODE=$(fw_exists $IROOT/elixir.installed)
 [ ! "$RETCODE" == 0 ] || { . $IROOT/elixir.installed; return 0; }
 
 fw_depends erlang
-export PATH=$PATH:$IROOT/erlang/bin
+source $IROOT/erlang.installed
 
-VERSION="1.0.4"
-fw_get https://codeload.github.com/elixir-lang/elixir/tar.gz/v$VERSION
-fw_untar v$VERSION
+VERSION="1.0.4-1"
+RELEASE="trusty"
+ARCH="amd64"
 
-(
-	mv elixir-$VERSION elixir
-	cd elixir
-	make compile
-)
+fw_get http://packages.erlang-solutions.com/site/esl/elixir/FLAVOUR_2_download/elixir_${VERSION}~ubuntu~${RELEASE}_${ARCH}.deb
+dpkg -x elixir_${VERSION}~ubuntu~${RELEASE}_${ARCH}.deb $IROOT/elixir
+$IROOT/erlang/usr/lib/erlang/Install -minimal $IROOT/erlang/usr/lib/erlang
 
-echo "export PATH=$IROOT/erlang/bin:$IROOT/elixir/bin:$PATH" >> $IROOT/elixir.installed
+echo "export PATH=\$IROOT/elixir/usr/local/bin:\$IROOT/erlang/usr/bin:\$PATH" >> $IROOT/elixir.installed

+ 7 - 11
toolset/setup/linux/languages/erlang.sh

@@ -3,16 +3,12 @@
 RETCODE=$(fw_exists $IROOT/erlang.installed)
 [ ! "$RETCODE" == 0 ] || { . $IROOT/erlang.installed; return 0; }
 
-export OTP_SRC="otp_src_17.5"
-fw_get http://www.erlang.org/download/${OTP_SRC}.tar.gz
-fw_untar ${OTP_SRC}.tar.gz
+VERSION="17.4-2"
+RELEASE="trusty"
+ARCH="amd64"
 
-(
-	cd $OTP_SRC
-	export ERL_TOP=`pwd`
-	./configure --prefix=$IROOT/erlang --without-termcap
-	make
-	make install
-)
+fw_get http://packages.erlang-solutions.com/site/esl/esl-erlang/FLAVOUR_1_esl/esl-erlang_${VERSION}~ubuntu~${RELEASE}_${ARCH}.deb
+dpkg -x esl-erlang_${VERSION}~ubuntu~${RELEASE}_${ARCH}.deb $IROOT/erlang
+$IROOT/erlang/usr/lib/erlang/Install -minimal $IROOT/erlang/usr/lib/erlang
 
-echo "export PATH=$IROOT/erlang/bin:$PATH" >> $IROOT/erlang.installed
+echo "export PATH=\$IROOT/erlang/usr/bin:\$PATH" >> $IROOT/erlang.installed

+ 0 - 15
toolset/setup/linux/systools/rebar.sh

@@ -1,15 +0,0 @@
-#!/bin/bash
-
-RETCODE=$(fw_exists $IROOT/rebar.installed)
-[ ! "$RETCODE" == 0 ] || { return 0; }
-
-fw_depends erlang
-source $IROOT/erlang.installed
-
-fw_get https://github.com/rebar/rebar/archive/2.5.1.tar.gz -O rebar-2.5.1.tar.gz
-fw_untar rebar-2.5.1.tar.gz
-mv rebar-2.5.1 rebar
-cd rebar
-./bootstrap
-
-echo "export REBAR_HOME=$IROOT/rebar" >> $IROOT/rebar.installed