跳到主要内容

快速开始

本页帮助首次使用人员完成三件事:启动 Watchdog、登录 Web 页面、确认 GatewayRuntime 已正常运行。Studio 是额外的工程开发与远程发布工具,普通网关运行不要求启动 Studio。

使用目标与管理入口

服务默认地址用途
Studio(可选)http://<服务器IP>:5100创建、导入、验证和远程发布工程。普通网关运行不依赖 Studio。
GatewayRuntimehttp://<网关IP>:6100配置采集、变量、规则、报警、转发和权限。
Watchdoghttp://<网关IP>:6200守护网关进程,管理项目和备份。

Watchdog 和 GatewayRuntime 部署在网关设备上,是运行网关所需的服务。Watchdog 负责启动和守护 GatewayRuntime。需要集中开发工程或向远端网关发布工程时,再在工程师使用的管理服务器或电脑上单独部署 Studio。

前置条件

检查项要求
操作系统使用产品支持的 Windows 或 Linux 系统。
运行环境GatewayRuntime、Studio 和 Watchdog 的普通发布包都需要安装 .NET 10 Runtime;Studio 与 Watchdog 还需额外安装 .NET 10 ASP.NET Core Runtime;独立运行或 AOT 发布包不需要另装 .NET Runtime。
网络端口确认 GatewayRuntime 的 6100 和 Watchdog 的 6200 没有被其它程序占用。使用 Studio 时再检查 5100。远程访问时放行实际使用的端口。
Studio 文件(可选)使用 Studio 时,Windows 发布包中确认存在 ThingsGatewayStudio.exe,Linux 发布包中确认存在 ThingsGatewayStudio。不要单独移动该文件。
Watchdog 文件Windows 发布包中确认存在 ThingsGatewayRuntime.Watchdog.exe;Linux 发布包中确认存在 ThingsGatewayRuntime.Watchdog
运行目录保持程序同目录下的 GatewayAppProjectsConfiguration 等目录完整,并确保运行账号具有读写权限。
系统权限Windows 安装服务时使用管理员权限;Linux 先为程序授予执行权限。
默认账号当前随包默认账号为 admin,默认密码为 111111。首次登录后立即修改密码。

启动操作

首次使用时建议先直接启动 Watchdog,确认 Watchdog 和 GatewayRuntime 两个 Web 地址都能访问后,再配置开机自动启动。

Windows 直接启动

在网关设备打开 PowerShell,进入 Watchdog 发布目录并启动:

Set-Location 'D:\ThingsGateway\WatchDog'
.\ThingsGatewayRuntime.Watchdog.exe

示例中的目录需要替换为实际解压目录。请从程序所在目录启动,不要只复制可执行文件到其它位置。

需要使用 Studio 时,在 Studio 所在电脑另行启动:

Set-Location 'D:\ThingsGateway\Studio'
.\ThingsGatewayStudio.exe

Linux 直接启动

在网关设备执行:

cd /opt/ThingsGateway/WatchDog
chmod +x ThingsGatewayRuntime.Watchdog
./ThingsGatewayRuntime.Watchdog

示例中的 /opt/ThingsGateway 需要替换为实际解压目录。

需要使用 Studio 时,在 Studio 所在电脑另行启动:

cd /opt/ThingsGateway/Studio
chmod +x ThingsGatewayStudio
./ThingsGatewayStudio

Watchdog 随包默认启用 GatewayRuntime 自动启动。Watchdog 启动后,会检查并启动同目录 GatewayApp 中的 ThingsGatewayRuntime.exeThingsGatewayRuntime。如果尚未应用工程,先登录 Watchdog 上传并应用工程,或通过 Studio 发布工程。

通过标准

  1. 打开 http://<网关IP>:6200,确认 Watchdog 登录页可以访问。
  2. 登录 Watchdog,在“仪表盘”确认 GatewayRuntime 状态为运行中。
  3. 打开 http://<网关IP>:6100,确认 GatewayRuntime 登录页可以访问。
  4. 已部署 Studio 时,再打开 http://<Studio服务器IP>:5100 确认其登录页可以访问。

Windows 服务

确认直接启动正常后,以管理员身份打开 PowerShell。先填写 Watchdog 的实际程序路径,再创建并启动服务:

$watchdogExe = 'D:\ThingsGateway\WatchDog\ThingsGatewayRuntime.Watchdog.exe'

sc.exe create ThingsGatewayWatchdog binPath= "`"$watchdogExe`"" start= auto DisplayName= "ThingsGateway Watchdog"

sc.exe start ThingsGatewayWatchdog

Get-Service ThingsGatewayWatchdog

Get-Service 显示 Watchdog 为 Running 后,再访问 Watchdog 和 GatewayRuntime 地址。服务启动失败时,先核对程序路径和运行目录权限,再到 Windows 事件查看器中查看错误。只有需要 Studio 长期运行时,才按相同方式为 Studio 单独创建服务。

Linux 服务

确认直接启动正常后,在网关设备创建 /etc/systemd/system/thingsgateway-watchdog.service

[Unit]
Description=ThingsGateway Watchdog
After=network.target

[Service]
Type=simple
User=thingsgateway
WorkingDirectory=/opt/ThingsGateway/WatchDog
ExecStart=/opt/ThingsGateway/WatchDog/ThingsGatewayRuntime.Watchdog
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

UserWorkingDirectoryExecStart 替换为实际运行账号和安装目录。该账号必须对 Watchdog、GatewayAppProjects 目录具有读写权限。

启用并启动服务:

sudo systemctl daemon-reload
sudo systemctl enable thingsgateway-watchdog
sudo systemctl start thingsgateway-watchdog
sudo systemctl status thingsgateway-watchdog

状态显示 active (running) 后,再访问 Watchdog 和 GatewayRuntime 地址。只有需要 Studio 长期运行时,才按相同方式为 Studio 单独创建服务,并把工作目录和启动文件替换为 Studio 的实际路径。

登录 GatewayRuntime

访问 http://<网关IP>:6100,输入账号和密码,点击“登录”。

GatewayRuntime 登录页

登录成功后进入“系统总览”。

GatewayRuntime 系统总览

登录后首次巡检

步骤页面检查内容
1系统总览页面可以访问,工程信息和系统资源没有明显异常。
2采集配置通道、设备和变量已经加载;目标设备没有持续离线。
3数据转发转发组和目标已启用,最近活跃时间持续更新。
4系统日志没有持续出现连接、认证、读写或保存错误。
5用户管理修改默认密码,并按人员职责分配账号权限。

登录 Studio(可选)

访问 http://<服务器IP>:5100,登录 Studio。

Studio 登录页

登录后可以在“我的工程”中创建或导入工程,在“看门狗”中维护网关连接,在发布前启动本地运行环境进行验证。

Studio 工程管理界面

登录 Watchdog

访问 http://<网关IP>:6200,登录 Watchdog。

Watchdog 登录页

登录后可在仪表盘查看网关进程、运行参数和日志。

Watchdog 仪表盘

常见问题

现象处理建议
浏览器无法打开页面确认对应服务已经启动、端口没有被占用,并检查防火墙。
本机可以访问,设备 IP 无法访问确认服务监听地址、远程管理设置和网络防火墙规则。
登录失败确认账号密码、用户是否启用;确认密码没有输入多余空格。
登录后又回到登录页检查服务是否刚刚重启,刷新页面后重新登录。
Studio 看不到 Watchdog从 Studio 所在电脑访问 Watchdog 地址,检查网络、账号和 Watchdog 日志。
GatewayRuntime 没有自动启动打开 Watchdog 查看项目是否已应用,以及网关进程是否启动失败。

下一步