Giter VIP home page Giter VIP logo

turn_api's Introduction

TURN API

Node.js app that polls a Cassandra database for the most recent utilization available about available TURN servers in the cluster and provides a web API for clients to query in order to get a list of available TURN servers sorted in order of least-utilized.

Prerequsites

git node.js forever Cassandra

/opt/logs directory (writeable by the user account that will run the server process)

The installation instructions for these items is beyond the scope of this readme file.

Installation and configuration

cd /opt/
sudo git clone https://[email protected]/CommsOps/turn_api.git
cd /opt/turn_api
sudo npm install

Configuration files for are stored in the /config folder. Every logical data center location should have its own configuration file. If necessary, create a new configuration file with an appropriate environment or data center suffix. (for example, wbrn, stg, qa2)

Sample configuration:

module.exports = { 

  cassandra_config : {
    hosts : ['YOUR_CASSANDRA_HOST_IP'],
    keyspace : 'turn_stats_db'
  },
  
  max_server_count: 1

}

Explanation:

hosts: the IP address of the Cassandra host (in most cases, this is the localhost that's running the turn_api server)

keyspace: the Cassandra keyspace (database) name

max_server_count: number of TURN servers to return when a client requests available turn resources

Execution

The init script is located in the scripts directory of this repository. It will need to be modified to load the correct configuration file.

The environment variable NODE_ENV needs to be set with an environment name that matches its corresponding config in config. For example, to load config_wbrn.js set NODE_ENV to "wbrn", to load config_qa2.js set NODE_ENV to "qa2".

First, install the init script as follows:

sudo cp /opt/turn_api/script/turn_api /etc/init.d/turn_api
sudo chmod +x /etc/init.d/turn_api
sudo chkconfig --add turn_api
sudo chkconfig --level 35 turn_api on

Then, edit the /etc/init.d/turn_api script on line 17 to set the NODE_ENV variable to match your environment.

To start the service:

sudo service turn_api start

To stop the service:

sudo service turn_api stop

Verification

First, verify that the application is correctly generating a log file in:

cat /opt/logs/turn_api_app_log.txt

Second, verify that the application webserver is accessible via web browser through the following URL endpoint:

http://YOUR_HOST_NAME:8080/getTURNServerArray

Cassandra keyspace & table definition

Deleting old keyspace.

First, open Cassandra the command line tool.

/usr/src/apache-cassandra-2.0.7/bin/cqlsh

OR

/usr/src/apache-cassandra-2.0.7/bin/cassandra-cli

(certain commands work in one tool but not the other..)

Delete old keyspace

drop keyspace turn_stats_db;

Creating keyspace & table:

Copy and paste the following scripts into the Cassandra cli:

create keyspace turn_stats_db
  with placement_strategy = 'NetworkTopologyStrategy'
  and strategy_options = {'datacenter1' : 2, 'datacenter2' : 2}
  and durable_writes = true;

Table:

  CREATE TABLE turn_lb (
  server_id text,
  active_connections int,
  cpu_percentage text,
  mem_usage text,
  pid text,
  timestamp int,
  turn_server_ip text,
  PRIMARY KEY (server_id)
) WITH
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=864000 AND
  index_interval=128 AND
  read_repair_chance=0.100000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  default_time_to_live=0 AND
  speculative_retry='99.0PERCENTILE' AND
  memtable_flush_period_in_ms=0 AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={'sstable_compression': 'LZ4Compressor'};

turn_api's People

Contributors

bkozlik avatar commsops avatar

Watchers

 avatar

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.