源码安装
从源码安装ThingsBoard Gateway,请按以下步骤操作:
1.使用apt安装所需系统库:
1
sudo apt install python3-dev python3-pip python3-venv libglib2.0-dev git
2.从GitHub克隆仓库:
1
git clone --recurse-submodules https://github.com/thingsboard/thingsboard-gateway.git --depth 1
3.进入克隆目录:
1
cd thingsboard-gateway
4.创建并激活虚拟环境:
1
python3 -m venv venv && source venv/bin/activate
5.安装Python依赖:
1
pip install -r requirements.txt
6.安装库:
1
python setup.py install
7.创建「logs」目录:
1
mkdir logs
8.配置网关以连接你的ThingsBoard实例:在tb_gateway.json配置文件中修改「host」和「accessToken」为你的值。 该文件说明见IoT Gateway配置指南。
tb_gateway.json位于config目录:
1
thingsboard-gateway/thingsboard_gateway/config
9.运行网关以验证安装:
1
python3 ./thingsboard_gateway/tb_gateway.py
构建本地Docker镜像
构建本地Docker镜像,请按以下步骤操作:
1.将Dockerfile复制到根目录:
1
cp docker/Dockerfile .
2.在项目根目录执行:
1
docker build -t local-gateway .
热重载
开发环境使用时,可启用热重载功能,在编辑任意项目文件时自动重启网关。
启用热重载功能运行网关,执行:
1
python3 ./thingsboard_gateway/tb_gateway.py true