poa-netstats-warehouse/doc/POABackend.html

175 lines
7.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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.0">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-3739fd4c82.js"></script>
</head>
<body data-type="modules">
<script>try { if(localStorage.getItem('night-mode')) document.body.className += ' night-mode'; } catch (e) { }</script>
<div class="main">
<button class="sidebar-button sidebar-toggle">
<span class="icon-menu" aria-hidden="true"></span>
<span class="sr-only">Toggle Sidebar</span>
</button>
<button class="sidebar-button night-mode-toggle">
<span class="icon-theme" aria-hidden="true"></span>
<span class="sr-only">Toggle Theme</span>
</button>
<section class="sidebar">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
</h1>
<h2 class="sidebar-projectVersion">
v0.1.0
</h2>
</div>
</a>
<form class="sidebar-search" action="search.html">
<button type="submit" class="search-button">
<span class="icon-search" aria-hidden="true"></span>
</button>
<input name="q" type="text" id="search-list" class="search-input" placeholder="Search" aria-label="Search" autocomplete="off" />
</form>
<ul class="sidebar-listNav">
<li><a id="extras-list" href="#full-list">Pages</a></li>
<li><a id="modules-list" href="#full-list">Modules</a></li>
</ul>
<div class="gradient"></div>
<ul id="full-list" class="sidebar-fullList"></ul>
</section>
<section class="content">
<div class="content-outer">
<div id="content" class="content-inner">
<h1>
<small class="visible-xs">poa_backend v0.1.0</small>
POABackend
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend.ex#L1" title="View Source" class="view-source" rel="help">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</h1>
<section id="moduledoc">
<h1>POABackend</h1>
<p><a href="https://coveralls.io/github/poanetwork/poa-netstats-warehouse?branch=master"><img src="https://coveralls.io/repos/github/poanetwork/poa-netstats-warehouse/badge.svg?branch=master" alt="Coverage Status"/></a>
<a href="https://codecov.io/gh/poanetwork/poa-netstats-warehouse"><img src="https://codecov.io/gh/poanetwork/poa-netstats-warehouse/branch/master/graph/badge.svg" alt="codecov"/></a></p>
<p>Storage and data-processing companion for the <a href="https://github.com/poanetwork/poa-netstats-agent">poa-netstats-agent</a></p>
<h2 id="module-documentation" class="section-heading">
<a href="#module-documentation" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Documentation
</h2>
<ul>
<li><a href="pages/initial_architecture.md">Initial Architecture</a>
</li>
<li>You can find the online documentation <a href="index.html">here</a>
</li>
</ul>
<p>Or you can build the documenation locally running</p>
<pre><code class="elixir">mix deps.get
mix docs</code></pre>
<p>That command will create a <code class="inline">doc/</code> folder with the actual Documentation.</p>
<h2 id="module-run-tests" class="section-heading">
<a href="#module-run-tests" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Run Tests
</h2>
<p><a href="POABackend.html#content"><code class="inline">POABackend</code></a> uses <a href="http://erlang.org/doc/man/mnesia.html">Mnesia</a> as a local database with <a href="https://hexdocs.pm/ecto/Ecto.html">Ecto</a>. In order to have this running we have to create a folder where <code class="inline">Mnesia</code> will store our data. In order to do that we have to define it in the <code class="inline">config/test.exs</code> file like this:</p>
<pre><code class="elixir">config :mnesia,
dir: &#39;your/local/path&#39; # make sure this directory exists!</code></pre>
<p>once we have the path defined we have to create the database (those commands must be run only once if you are going to use always this same path for testing). In your root folder run:</p>
<pre><code class="elixir">MIX_ENV=test mix ecto.create
MIX_ENV=test mix ecto.migrate</code></pre>
<p>Now the environment is set. We can run the tests with:</p>
<pre><code class="elixir">mix test</code></pre>
<p><a href="POABackend.html#content"><code class="inline">POABackend</code></a> comes also with a code analysis tool <a href="https://github.com/rrrene/credo">Credo</a> and a types checker tool <a href="https://github.com/jeremyjh/dialyxir">Dialyxir</a>. In order to run them we have to run</p>
<pre><code class="elixir">mix credo
mix dialyzer</code></pre>
<h2 id="module-building-deploying-an-executable" class="section-heading">
<a href="#module-building-deploying-an-executable" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Building &amp; Deploying an Executable
</h2>
<p>To build an executable youll need Elixir 1.6 (and Erlang/OTP 20).</p>
<ol>
<li>Once you have a copy of this repository configure the backend for production in the file <code class="inline">config/prod.exs</code>.
</li>
<li>An example configuration can be found in the current <code class="inline">config/prod.exs</code>.
</li>
<li>Do a <code class="inline">mix deps.get</code> to fetch, among other dependencies, the tooling for building server executables.
</li>
<li>A <code class="inline">env MIX_ENV=prod mix release --name=poa_backend --env=prod</code> will assemble an executable.
</li>
</ol>
<p>A resulting artifact resides at <code class="inline">_build/prod/rel/poa_backend/releases/0.1.0/poa_backend.tar.gz</code> which you can move to a remote host.
Use <code class="inline">tar xfz</code> then <code class="inline">bin/poa_agent start</code> (<code class="inline">bin/poa_agent stop</code> will stop the server cleanly).</p>
<p>If you want to run it on the local host then the procedure is as simple as: <code class="inline">_build/prod/rel/poa_backend/bin/poa_backend</code>.</p>
<p><strong>Note:</strong> executables must be built on the platform (OS and architecture) they are destined for under the projects current configuration.
Other options are possible (see <code class="inline">https://hexdocs.pm/distillery/getting-started.html</code>).</p>
</section>
<footer class="footer">
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by
<a href="https://twitter.com/dignifiedquire" target="_blank" title="@dignifiedquire">Friedel Ziegelmayer</a>.
</span>
</p>
</footer>
</div>
</div>
</section>
</div>
<script src="dist/app-9bd040e5e5.js"></script>
</body>
</html>