Commit 113857f4 authored by KT315's avatar KT315

Mochiweb

parent bb9f4d7f
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
# The directory Mix will write compiled artifacts to.
/_build/
# If you run "mix test --cover", coverage assets end up here.
/cover/
# The directory Mix downloads your dependencies sources to.
/deps/
# Where 3rd-party dependencies like ExDoc output generated docs.
/doc/
# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch
# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump
# Also ignore archive artifacts (built via "mix archive.build").
*.ez
# Ignore package tarball (built via "mix hex.build").
elixir_dummy-*.tar
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config
defmodule Dummy do
@moduledoc false
@body "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis dictum ligula, ut sagittis nisl malesuada nec. Fusce hendrerit leo augue, nec pretium dolor porta sodales. Sed consequat sed purus eu aliquet. Etiam laoreet nibh vel ex sodales, non egestas lorem tempor. Pellentesque placerat facilisis felis, nec bibendum metus finibus quis. Donec lobortis, sapien at tristique placerat, nibh libero volutpat eros, eget mollis nibh elit et enim. Vestibulum consequat ut lorem sed eleifend. Ut eu dolor ut lectus faucibus rhoncus. Nam vestibulum vitae massa vel congue. Nam ac odio lacus. Nam condimentum ante eget mollis vestibulum. Cras nisi sapien, tempor nec diam at, vulputate cursus odio. Maecenas vitae tellus efficitur arcu mollis ultrices id vitae ex. Suspendisse potenti. Duis nec vestibulum dui. Donec ultricies sit amet lorem eu feugiat. Ut pretium vitae lectus at tempor. Curabitur condimentum arcu varius nulla ultricies, id feugiat odio dictum. Vivamus sollicitudin consectetur nullam."
def loop(req) do
Process.sleep(100 + (5 - trunc(:rand.uniform() * 10)))
:mochiweb_request.ok({"text/plain", [], @body}, req)
end
end
defmodule Dummy.Application do
@moduledoc false
use Application
def start(_type, _args) do
children = [
%{
id: :dummy,
start: {:mochiweb_http, :start, [[name: Dummy, loop: {Dummy, :loop}, port: 5000]]},
restart: :permanent,
shutdown: :infinity,
type: :supervisor
}
]
opts = [strategy: :one_for_one, name: Dummy.Supervisor]
Supervisor.start_link(children, opts)
end
end
defmodule Dummy.MixProject do
use Mix.Project
def project do
[
app: :elixir_dummy,
version: "0.1.0",
elixir: "~> 1.9",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end
def application do
[
extra_applications: [:logger],
mod: {Dummy.Application, []}
]
end
defp deps do
[
{:mochiweb, git: "https://github.com/mochi/mochiweb.git", tag: "v2.20.0"}
]
end
end
%{
"mochiweb": {:git, "https://github.com/mochi/mochiweb.git", "cedc22f66a8e3f3885fb06babc0c0582418508f8", [tag: "v2.20.0"]},
}
#!/bin/bash
ulimit -n 100000
./elixir_dummy/bin/elixir_dummy start > log 2>&1 &
\ No newline at end of file
#!/bin/bash
kill -9 $(./elixir_dummy/bin/elixir_dummy pid)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment