Skip to content

Commit

Permalink
Applied MR Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vvoluom committed May 11, 2020
1 parent ce38f11 commit da57426
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 324 deletions.
11 changes: 4 additions & 7 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
.idea/
.vscode/

__pycache__
config

src/src
oasis_api_server
config/user_config_main.ini
config/user_config_nodes.ini
config/user_config_sentry.ini
config/tls_identity_cert.pem
.vscode/
oasis_api_server
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.idea/
.vscode/

__pycache__/

src/src
oasis_api_server
config/user_config_main.ini
config/user_config_nodes.ini
config/user_config_sentry.ini
config/tls_identity_cert.pem
.vscode/
2 changes: 1 addition & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 1.0.0

Released on March 2020
Released on May 2020

### Added

Expand Down
24 changes: 21 additions & 3 deletions docs/INSTALL_AND_RUN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Install and Run the Oasis API Server

## Configuring the Nodes

In order for the API to be able to run correctly, Prometheus Metrics should be enabled in the Oasis node's configuration file `config.yml` in the `/serverdir/etc/` directory which was set during the installation of the Oasis Node. To enable the metrics append this to the end of the file :

```
Expand All @@ -12,6 +13,7 @@ metrics:
Change `:9090` to the port you want prometheus to be exposed at.

## Configuring the API

Configuring the API involves setting up three config files. This is a strict requirement for the API to be able to run.

Start off by cloning this repository and navigating into it:
Expand All @@ -37,9 +39,11 @@ pipenv sync
pipenv run python run_setup.py
```
### Manually

Alternatively, for advanced users, you can make a copy of the `example_*.ini` files inside the `config` folder without the `example_` prefix, and manually change the values as required.

## Installing the API and Dependencies

This section will guide you through the installation of the API and any of its dependencies.

We recommend that the API is installed on a Linux system, given the simpler installation and running process.
Expand All @@ -49,19 +53,23 @@ You can either [run the API from source](#running-from-source) or [run the API u
This affects what dependencies you will need to install.

### Running from Source

Running the API from source only requires you to install Golang.

#### Install Golang

It is assumed that since this API needs to be run on the same machine as the Oasis node then Golang is already installed,
therefore no documentation is provided for it's installation,

#### Running the API

After having installed golang you can now run the API as follows from the project directory:
```bash
bash run_api.sh
```

#### Running the API as a Linux Service

Running the API as a service means that it starts up automatically on boot and restarts automatically if it runs into some issue and stops running. To do so, we recommend the following steps:
```bash
# Add a new user to run the API
Expand Down Expand Up @@ -109,17 +117,21 @@ Check out `systemctl status oasis_api_server` to confirm that the API is running


### Run using Docker

To run the API using Docker, you shouldn't be surprised to find out that you need to install Docker.

You will then obtain the Docker image, make sure that the config files are where they should be, and run everything.

#### Installing Docker on your Machine

To install Docker on your machine, follow [this guide](INSTALL_DOCKER.md)

#### Obtaining the Docker Image

This part can be done in either of two ways, either by building the Docker image yourself, or by downloading it from Docker Hub.

##### Building the Docker Image

First start off by cloning this repository:
```bash
git clone https://github.com/SimplyVC/oasis_api_server
Expand All @@ -133,38 +145,44 @@ docker build -t simplyvc/oasis_api_server:1.0.0 .


##### Downloading the Pre-Built Docker Image from DockerHub

The pre-built Docker image can simply be downloaded by running the following command:
```bash
docker pull simplyvc/oasis_api_server:1.0.0
```

#### Config Files Directory and Permissions

The config files needed by the Docker image are the same as those generated in the `Configuring the API` section above.\
These config files can be moved to any directory of your choosing `<CONFIG_DIR>`.

##### On Ubuntu

If you created a new user `<USER>` earlier on, set the permissions as follows:
```bash
sudo chown -R <USER>:<USER> <CONFIG_DIR>
```

##### On Windows

No further steps are required.

#### Running the Docker Image

Now that the Docker image is on your machine, and you have written configurations for it, you can run it as follows, where `<CONFIG_DIR>` is the **full path** to the folder containing the previously created config files. Suppose that <CONFIG_DIR> is the **full path** to the folder containing the previously created config files, <INTERNAL_SOCK_DIR> is the **full path** on your machine where the internal socket file can be found for the Oasis node (e.g: serverdir/node/), and <PATH_IN_NODE_CONFIG> is the specified location in the API setup where the API will look for the internal socket (e.g: serverdir/node/). The API Server must also be able to find the **full path** of the Sentry `tls_identity_cert.pem` files. Therefore the path <INTERNAL_TLS_DIR> is the **full path** on your machine where the `tls_identity_cert.pem` file can be found, and <PATH_IN_SENTRY_CONFIG> is the specified location in the API setup where the API will look for the `tls_identity_cert.pem` file (e.g: serverdir/etc/). Now that the Docker image is on your machine and you have written configuration for it, you can run it as follows:
```bash
docker run --network="host" -p 127.0.0.1:8686:8686 \
-v <CONFIG_DIR>:/app/config/ \
-v <INTERNAL_SOCK_DIR>:<PATH_IN_NODE_CONFIG> \
-v <INTERNAL_TLS_DIR>:<PATH_IN_SENTRY_CONFIG> \
--mount type=bind,source=<CONFIG_DIR>,target=/app/config/ \
--mount type=bind,source=<INTERNAL_SOCK_DIR>,target=<PATH_IN_NODE_CONFIG> \
--mount type=bind,source=<INTERNAL_TLS_DIR>,target=<PATH_IN_SENTRY_CONFIG> \
-d simplyvc/oasis_api_server:1.0.0
```

Note: The port after `-p` and before the `:` can be used to route a port from the machine to the internal port of the Docker. If changing this, any program which refers to the API Docker container must refer to this port.\
Example: with `5678`:3000, the the API URL must look like `http://1.2.3.4:5678`, i.e. the port must match `5678`, and not 3000.

## Confirming the API Works

If you wish to make sure that the API is running, the following should return `{"result":"pong"}`:
```bash
curl -X GET http://localhost:3000/api/pingapi
Expand Down
3 changes: 3 additions & 0 deletions docs/INSTALL_DOCKER.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Installing Docker

## On Ubuntu

First, install Docker on your machine:
```bash
sudo apt update
Expand All @@ -19,6 +20,7 @@ docker --version
```

### Creating a new user

You should create a new user from which you will run the Docker images. This is not required, but suggested for security reasons.
```bash
sudo adduser oasis_api_server
Expand All @@ -36,6 +38,7 @@ su oasis_api_server
```

## On Windows

Download and Install the `Stable` version of `Docker Desktop for Windows` from [here](https://hub.docker.com/editions/community/docker-ce-desktop-windows).\
Once it has installed, you must Log out and back in in order for the installation to complete

Expand Down
8 changes: 8 additions & 0 deletions docs/INSTALL_NODE_EXPORTER.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,31 @@
[Github](https://github.com/prometheus/node_exporter) link to most recent version of Node Exporter.

### Create a Node Exporter user for running the exporter:

```
sudo useradd --no-create-home --shell /bin/false node_exporter
```

### Download and extract the latest version of Node Exporter:

```
wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
tar -xzvf node_exporter-0.18.1.linux-amd64.tar.gz
```

### Send the executable to /usr/local/bin:

```
sudo cp node_exporter-0.18.1.linux-amd64/node_exporter /usr/local/bin/
```

### Give the Node Exporter user ownership of the executable:

```
sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter
```
### Perform some cleanup and create and save a Node Exporter service with the below contents:

```
sudo rm node_exporter-0.18.1.linux-amd64 -rf
sudo nano /etc/systemd/system/node_exporter.service
Expand Down
Binary file modified docs/SERVER.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/SERVER.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<mxfile host="app.diagrams.net" modified="2020-03-20T12:04:17.280Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" etag="fV9etpap1wrgD3Kei5WF" version="12.8.8"><diagram id="jlKB5raUCACtt_PIqlPo" name="Page-1">7VtRc+I2EP41zLQPYSzLNvAIhFzbSS6ZcHOX9k1gAeoZy5VFAvfrK9kyxpINvsQQ0sJDYq2ltfx9q93VIlpwuFx/Yiha3FEfBy3b8tcteN2ybQDsnvgnJZtU4jluKpgz4qtOuWBMfmAltJR0RXwcFzpySgNOoqJwSsMQT3lBhhijL8VuMxoUnxqhOTYE4ykKTOk34vNFKu3anVz+GybzRfZk4KkXXqKss3qTeIF8+rIjgqMWHDJKeXq1XA9xIMHLcEnH3VTc3U6M4ZDXGfDt+q+vXcd+Av74sWtP/NXSj69gquUZBSv1wv0pp0zNmG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KZDVj0FB64GlL37FcMz0oAREcDUT7A4IIzw1Es8R1/iD2zg1EM76fP4jeuYFoRnITxNDvy2/WZKQJUByTaVXFHBQq5m0ra9Yv86QPb6RaAyrKMDtQuyVQZ7I37r63+zM9+mUq0vmrUTmLhiKQ1cOzsqKnzSUtRxmKmtrMwzpR8wwt5N2IBzrx8HXE64qMOvGxia8T6S/E51uJpojXFZ2c+DrZyYX4fKOjeehXE68rOjnxNU4lXIjP+XKNuswridcVnZx4swp5IX4P8cA9wFft5M49YEHHJv6Dpv/vltw1Rbyu6OTEm1/dXojfl9w1Rbyu6NTEZ9vSC/E1k7umiNcVnZz4yz7+55I7pyHidUUnJ97czl0jjoTkRh5u0G3g9Ycs6p/UKSvGNn6yQjvPDIFZanVKzMe2qi3lbUe+zd3VHWXymz35BV/83yXC0wsjJUdcus0wIZr5DyzSBZT/TAWO/gU=</diagram></mxfile>
<mxfile host="app.diagrams.net" modified="2020-05-11T15:06:55.846Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36" etag="WPVBHedYlV5EHjsGYVNP" version="13.0.8" type="device"><diagram id="jlKB5raUCACtt_PIqlPo" name="Page-1">7Vrbcts2EP0azbQP5vB+eXRsy20njT1Wpkn6BpGQhDFJMCRkS/36LATeQECRLcu2OhEfNMLBjdhzsFhyOXIustV1iYrF3zTB6cg2k9XIuRzZduS48MuBtQC8BpiXJBGQ1QET8h+uQbNGlyTBldSQUZoyUshgTPMcx0zCUFnSR7nZjKbyrAWaYwWYxChV0S8kYQuBhnbQ4X9gMl80M1t+JGoy1DSuV1ItUEIfe5BzNXIuSkqZ+JetLnDKbdfYRfQbb6ltb6zEOXtKhy+X//4TuvZXK5nchfY0WWZJdeaIUR5QuqwX/AkYBOSmwCVitKzvna0bg8AyCv53maXnMW/gfHjAJSNgso9oitNbWhFGaA5NppQxmkGDlFd8QPH9vKTLPLmgKe8HozmzzdUb4zwlc96X0QLQBctSKFj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TXwmpSXk02WOAwT1elCG3/HGVVoJjkcwC8rvSZhzuXXOL61CSFG5ulGwEvSJJgCJEG6coZzZkuLNqqvaenMe1QPpx0if1II8NDpPX1nkD3MCVY42YY8U+JGkv435dUMFi/3epDPUYbkA9wVm2+YTqHBkGxGtnCjiZP7J81C+SVm4yf1x9QqEV8XHCVJ4XQ8zC3+tv11WdocIe/L3HFfu8pTtz+wTV3yLz4z4X2shTbIIPaZlTfK2HenDAvFlrDqOgLmz5/sviGg/w1ufkEdWNaZogxoEWR1x2uCni4wbqkfqs0cQ8K/GsL0Amt3QLUfDmzh6eDYvfdoDjmuo8vnasf</diagram></mxfile>
Loading

0 comments on commit da57426

Please sign in to comment.