Giter Club home page Giter Club logo

smswithoutborders-telemetry-be's Introduction

SMSWithoutBorders-Telemetry

Requirements

Dependencies

On Ubuntu

$ sudo apt install python3-dev libmysqlclient-dev apache2 apache2-dev make libapache2-mod-wsgi-py3

Linux Environment Variables

Variables used for the Project:

  • MYSQL_HOST=STRING
  • MYSQL_USER=STRING
  • MYSQL_PASSWORD=STRING
  • MYSQL_DATABASE=STRING
  • SHARED_KEY=PATH
  • HOST=STRING
  • PORT=STRING
  • SSL_SERVER_NAME=STRING
  • SSL_PORT=STRING
  • SSL_CERTIFICATE=PATH
  • SSL_KEY=PATH
  • SSL_PEM=PATH
  • MODE=STRING

Installation

Install all python packages

Pip

$ python3 -m venv venv
$ . venv/bin/activate
$ pip install -r requirements.txt

How to use

Start API

Python

$ MYSQL_HOST= \
  MYSQL_USER= \
  MYSQL_PASSWORD= \
  MYSQL_DATABASE= \
  HOST= \
  PORT= \
  SSL_SERVER_NAME= \
  SSL_PORT= \
  SSL_CERTIFICATE= \
  SSL_KEY= \
  SSL_PEM= \
  MODE=production \
  python3 server.py

MOD_WSGI

$ MYSQL_HOST= \
  MYSQL_USER= \
  MYSQL_PASSWORD= \
  MYSQL_DATABASE= \
  HOST= \
  PORT= \
  SSL_SERVER_NAME= \
  SSL_PORT= \
  SSL_CERTIFICATE= \
  SSL_KEY= \
  SSL_PEM= \
  MODE=production \
  mod_wsgi-express start-server wsgi_script.py \
  --user www-data \
  --group www-data \
  --port '${PORT}' \
  --ssl-certificate-file '${SSL_CERTIFICATE}' \
  --ssl-certificate-key-file '${SSL_KEY}' \
  --ssl-certificate-chain-file '${SSL_PEM}' \
  --https-only \
  --server-name '${SSL_SERVER_NAME}' \
  --https-port '${SSL_PORT}'

Docker

Build

Build smswithoutborders-telemetry-backend development docker image

$ docker build --target development -t smswithoutborders-telemetry-backend .

Build smswithoutborders-telemetry-backend production docker image

$ docker build --target production -t smswithoutborders-telemetry-backend .

Run

Run smswithoutborders-telemetry-backend development docker image. Fill in all the neccessary environment variables

$ docker run -d -p 11000:11000 \
  --name smswithoutborders-telemetry-backend \
  --env 'MYSQL_HOST=' \
  --env 'MYSQL_USER=' \
  --env 'MYSQL_PASSWORD=' \
  --env 'MYSQL_DATABASE=' \
  --env 'HOST=' \
  --env 'PORT=' \
  smswithoutborders-telemetry-backend

Run smswithoutborders-telemetry-backend production docker image. Fill in all the neccessary environment variables

$ docker run -d -p 9000:9000 \
  --name smswithoutborders-telemetry-backend \
  --env 'MYSQL_HOST=' \
  --env 'MYSQL_USER=' \
  --env 'MYSQL_PASSWORD=' \
  --env 'MYSQL_DATABASE=' \
  --env 'HOST=' \
  --env 'PORT=' \
  --env 'SSL_SERVER_NAME=' \
  --env 'SSL_PORT=' \
  --env 'SSL_CERTIFICATE=' \
  --env 'SSL_KEY=' \
  --env 'SSL_PEM=' \
  --env 'MODE=production' \
  smswithoutborders-telemetry-backend

Read in a file of environment variables with --env-file command e.g. docker run -d -p 9000:9000 --name smswithoutborders-telemetry-backend --env-file myenv.txt smswithoutborders-telemetry-backend

logger

Python

$ python3 server.py --logs=debug

Docker

Container logs

$ docker logs smswithoutborders-telemetry-backend

API logs in container

$ docker exec -it smswithoutborders-telemetry-backend tail -f <path_to_mod_wsgi_error_logs>

API Endpoints

Get statistics

GET /statistics

{}
  • Success - 200
  • Server Error - 500

smswithoutborders-telemetry-be's People

Contributors

dependabot[bot] avatar promisefru avatar

smswithoutborders-telemetry-be's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.