Code Monkey home page Code Monkey logo

cbsignal_redis's Introduction

build

Make sure that the golang development environment is installed

git clone https://github.com/cdnbye/cbsignal_redis.git
cd cbsignal
make

or directly use compiled linux file cbsignal .

deploy

Make sure you have set up redis server, then edit config.yaml:

redis:
  host: REDIS_IP
  port: 6379
  dbname: 0
  is_cluster: false

Upload binary file, admin.sh and config.yaml to server, create cert directory with signaler.pem and signaler.key, then start service:

chmod +x admin.sh
sudo ./admin.sh start

test

import Hls from 'cdnbye';
var hlsjsConfig = {
    p2pConfig: {
        wsSignalerAddr: 'ws://YOUR_SIGNAL',
        // Other p2pConfig options provided by hlsjs-p2p-engine
    }
};
// Hls constructor is overriden by included bundle
var hls = new Hls(hlsjsConfig);
// Use `hls` just like the usual hls.js ...

Get real-time information of signal service

GET /info

Response:

Status: 200

{
  "ret": 0,
  "data": {
      "version"
      "current_connections"
      "cluster_mode"
      "num_goroutine"
      "num_per_map"
  }
}

Cluster Mode

Redis list is used to communicate between all nodes. You just need to add more instances to the same local network.

Run by Docker

The default redis address in default config is 127.0.0.1:6379

sudo docker run --net host --restart=unless-stopped -d cdnbye/cbsignal_redis:latest

Run by Docker with your own Config

mkdir config && cd config
touch config.yaml

Then cony your config to config.yaml, you can copy your SSL cert to this directory, then:

sudo docker run --net host --restart=unless-stopped -d -v "$(pwd)"/config:/cbsignal_redis/config  cdnbye/cbsignal_redis:latest

Related projects

  • cbsignal_node - High performance CDNBye signaling service written in node.js

go语言版的 CDNBye 信令服务器,可用于Web、安卓、iOS SDK等所有CDNBye产品

编译二进制文件

请先确保已安装golang开发环境

git clone https://github.com/cdnbye/cbsignal_redis.git
cd cbsignal
make

或者直接使用已经编译好的linux可执行文件 cbsignal

部署

首先确保内网中已经有redis服务, 编辑 config.yaml:

redis:
  host: REDIS_IP
  port: 6379
  dbname: 0
  is_cluster: false

将编译生成的二进制文件、admin.sh和config.yaml上传至服务器,并在同级目录创建cert文件夹,将证书和秘钥文件分别改名为signaler.pemsignaler.key放入cert,之后启动服务:

chmod +x admin.sh
echo -17 > /proc/$(pidof cbsignal)/oom_adj     # 防止进程被OOM killer杀死
sudo ./admin.sh start

测试

import Hls from 'cdnbye';
var hlsjsConfig = {
    p2pConfig: {
        wsSignalerAddr: 'ws://YOUR_SIGNAL',
        // Other p2pConfig options provided by hlsjs-p2p-engine
    }
};
// Hls constructor is overriden by included bundle
var hls = new Hls(hlsjsConfig);
// Use `hls` just like the usual hls.js ...

通过API获取信令服务的实时信息

GET /info

响应:

Status: 200

{
  "ret": 0,
  "data": {
      "version"
      "current_connections"
      "cluster_mode"
      "num_goroutine"
      "num_per_map"
  }
}

集群模式

节点之间采用Redis list进行通信,只需要在同一个内网中部署更多实例即可。

通过Docker部署

默认配置连接redis地址是127.0.0.1:6379

sudo docker run --net host --restart=unless-stopped -d cdnbye/cbsignal_redis:latest

通过Docker部署并自定义配置

mkdir config && cd config
touch config.yaml

config.yaml是你的自定义配置,可以在此配置证书文件等,然后运行:

sudo docker run --net host --restart=unless-stopped -d -v "$(pwd)"/config:/cbsignal_redis/config  cdnbye/cbsignal_redis:latest

相关项目

  • cbsignal_node - 基于node.js开发的高性能CDNBye信令服务

web浏览器目录:web

nginx 反代: location /tracker { proxy_pass http://localhost:8800; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; }

location /ws { proxy_pass http://localhost:8800/ws; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; }

cbsignal_redis's People

Contributors

snowinszu avatar maosheng 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.