2018-05-03 08:54:37 -07:00
# POAAgent
2018-05-15 05:41:28 -07:00
[![Coverage Status ](https://coveralls.io/repos/github/poanetwork/poa-netstats-agent/badge.svg?branch=master )](https://coveralls.io/github/poanetwork/poa-netstats-agent?branch=master)
2018-05-15 05:53:50 -07:00
[![codecov ](https://codecov.io/gh/poanetwork/poa-netstats-agent/branch/master/graph/badge.svg )](https://codecov.io/gh/poanetwork/poa-netstats-agent)
2018-05-15 05:41:28 -07:00
2018-05-08 11:58:27 -07:00
## Documentation
2018-07-06 13:59:27 -07:00
- [Initial Architecture ](pages/initial_architecture.md )
2018-08-20 17:35:56 -07:00
- [Getting Started ](pages/starting_guide.md )
2018-07-06 13:59:27 -07:00
- You can find the online documentation [here ](https://rawgit.com/poanetwork/poa-netstats-agent/master/doc/index.html )
Or you can build the documenation locally running
2018-05-08 11:58:27 -07:00
```
2018-07-06 13:59:27 -07:00
mix deps.get
2018-05-08 11:58:27 -07:00
mix docs
```
2018-07-06 13:59:27 -07:00
That command will create a `doc/` folder with the actual Documentation.
2018-05-03 08:54:37 -07:00
## Run
POAAgent is an Elixir application, in order to run it first we need to fetch the dependencies and compile it.
```
mix deps.get
mix deps.compile
mix compile
```
2018-05-21 06:35:39 -07:00
To run the Elixir application while under development it may be convenient to use:
`env MIX_ENV=dev mix run --no-halt` with an appropiate configuration in `/config/dev.exs` .
2018-05-03 08:54:37 -07:00
## Run Tests
In order to run the tests we have to run the command
```
mix test
```
`POAAgent` comes also with a code analysis tool [Credo ](https://github.com/rrrene/credo ) and a types checker tool [Dialyxir ](https://github.com/jeremyjh/dialyxir ). In order to run them we have to run
```
mix credo
mix dialyzer
2018-05-15 05:41:28 -07:00
```
2018-05-15 06:13:36 -07:00
2018-05-21 06:35:39 -07:00
## Building & Deploying an Executable
To build an executable you'll need Elixir 1.6 (and Erlang/OTP 20).
1. Once you have a copy of this repository configure the agent for production in the file `config/prod.exs` .
2018-07-09 07:09:42 -07:00
2. An real configuration example can be found in the default `config/prod.exs` .
2018-05-21 06:35:39 -07:00
3. Do a `mix deps.get` to fetch, among other dependencies, the tooling for building server executables.
4. A `env MIX_ENV=prod mix release --name=poa_agent --env=prod` will assemble an executable.
A resulting artifact resides at `_build/prod/rel/poa_agent/releases/0.1.0/poa_agent.tar.gz` which you can move to a remote host.
Use `tar xfz` then `bin/poa_agent start` (`bin/poa_agent stop` will stop the server cleanly).
If you want to run it on the local host then the procedure is as simple as: `_build/prod/rel/poa_agent/bin/poa_agent` .
**Note:** executables must be built on the platform (OS and architecture) they are destined for under the project's current configuration.
Other options are possible (see `https://hexdocs.pm/distillery/getting-started.html` ).
2018-05-28 08:10:45 -07:00
## Configuration
Executables are built with a configuration as described above.
2018-07-23 08:32:10 -07:00
However the transfers and collectors are configurable at run-time through a JSON configuration.
To configure this supply a path to a JSON file with the `config_overlay` key/value.
2018-05-28 08:10:45 -07:00
The following is an extract from [config/test.exs ](config/test.exs ):
```Elixir
config :poa_agent,
2018-07-10 13:33:52 -07:00
config_overlay: "config/config_overlay.json"
2018-05-28 08:10:45 -07:00
```
2018-07-10 13:33:52 -07:00
A corresponding example is provided in `config/config_overlay.json` :
2018-05-28 08:10:45 -07:00
```JSON
{
"POAAgent":{
2018-07-10 13:33:52 -07:00
"collectors":[
{
"id": "eth_information",
"url": "http://localhost:8546",
"name": "NewNodeName",
"contact": "mynewemail@gmail.com"
}
],
2018-05-28 08:10:45 -07:00
"transfers":[
{
2018-07-10 13:33:52 -07:00
"id": "rest_transfer",
"address": "http://localhost:4003",
"identifier": "NewIdentifier",
"secret": "newsecret"
2018-05-28 08:10:45 -07:00
}
]
}
}
```
The file can reside anywhere on the machine that the Elixir executable has access to.
The key/value pairs in the JSON configuration will replace the defaults specified in the Elixir configuration (i.e. `config/{dev,test,prod}.exs` ).
2018-05-15 06:13:36 -07:00
## Coverage
To get an HTML coverage report on your own machine try `env MIX_ENV=test mix coveralls.html` then open `cover/excoveralls.html` .
You can get a simple print-out with `env MIX_ENV=test mix coveralls` .