低空智控平台 后端go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
刘浩东 ff1cd94b1f feat:功能增加 2 weeks ago
cache feat: complete auth, account, media, and OBS workflows 4 weeks ago
client feat:充值续费 3 weeks ago
common feat:功能增加 2 weeks ago
config feat:init 4 weeks ago
handler feat:功能增加 2 weeks ago
live feat:功能增加 2 weeks ago
logger feat: implement device operations and live workflow 1 month ago
middleware feat: complete auth, account, media, and OBS workflows 4 weeks ago
mock feat:功能增加 2 weeks ago
model feat:功能增加 2 weeks ago
mqtt fix:任务执行超时修复 4 weeks ago
route feat:功能增加 2 weeks ago
service feat:功能增加 2 weeks ago
sql feat:功能增加 2 weeks ago
token feat: complete auth, account, media, and OBS workflows 4 weeks ago
tool fix:任务执行超时修复 4 weeks ago
vo feat:功能增加 2 weeks ago
websocket feat: implement device operations and live workflow 1 month ago
DESIGN.md feat: complete auth, account, media, and OBS workflows 4 weeks ago
Makefile feat: implement device operations and live workflow 1 month ago
README.md feat:功能增加 2 weeks ago
config-prod.yaml feat:功能增加 2 weeks ago
config.yaml feat:功能增加 2 weeks ago
go.mod fix:直播计费 3 weeks ago
go.sum fix:直播计费 3 weeks ago
main.go feat:充值续费 3 weeks ago
publish-prod.sh feat:init 4 weeks ago

README.md

laic-backend

低空智控平台 后端 Go 服务。

生产部署

部署脚本参考 D:/GoProject/roller-service/roller-manage/publish-prod.sh,使用 Supervisor 管理服务。

服务器准备

在生产服务器安装 Supervisor。生产配置保存在仓库根目录的 config-prod.yaml,部署脚本会将它上传为服务器部署目录中的 config.yaml

sudo apt update
sudo apt install supervisor -y
sudo systemctl enable --now supervisor

生产配置至少包含:

oss:
  endpoint: https://obs.cn-east-2.myhuaweicloud.com
  access-key: 实际的华为云 OBS AK
  secret-key: 实际的华为云 OBS SK
  bucket: gcs-edu
  region: cn-east-2
  use-ssl: true

后端启动时直接读取部署目录下的 config.yaml。本地开发不设置 LAIC_CONFIG_FILE 时读取本地 config.yaml;Supervisor 显式设置 LAIC_CONFIG_FILE=config.yaml

执行部署

修改 publish-prod.sh 顶部的 REMOTEREMOTE_DIR 和服务参数,然后执行:

chmod +x publish-prod.sh
./publish-prod.sh

脚本会完成:

  1. 交叉编译 Linux amd64 二进制。
  2. 创建远程部署目录、日志目录和备份目录。
  3. 备份旧二进制和 config.yaml(首次部署没有旧文件时跳过)。
  4. 将本地 config-prod.yaml 上传为远程 config.yaml
  5. 更新 Supervisor 配置、重启服务并检查状态。
  6. 启动失败时自动恢复最近的旧二进制。

首次部署前确认远程服务器已安装并运行 Supervisor:

sudo apt update
sudo apt install supervisor -y
sudo systemctl enable --now supervisor

查看状态和日志:

sudo supervisorctl status laic-backend-prod
sudo tail -f /usr/local/laic-backend-prod/log/info.log
sudo tail -f /usr/local/laic-backend-prod/log/err.log

部署目录和服务名可以在 publish-prod.sh 顶部调整。回滚时,脚本会使用远程 backup/ 目录中最近的二进制备份;也可以手工恢复后执行:

sudo supervisorctl restart laic-backend-prod

Payment and SIM schema reconciliation

If a production database was upgraded from an older partial release, back it up first and then run sql/019_reconcile_payment_schema.sql. The migration is repeatable and fills missing traffic_order.updated_at, payment fields, pending order guards, and normalizes legacy empty payment idempotency keys. It also creates the payment/SIM tables. It does not create orders, charge users, or create SIM cards. Verify the schema and platform resource pool after it finishes, then restart the backend before retrying payment.

AGPay returns the WeChat QR code as binary image/png. The backend converts it to a JSON-safe providerPayload data URI (data:image/png;base64,...); clients should use that value directly as the image src and must not UTF-8 decode the original response body.

Test traffic grant

For QA environments, set the following configuration explicitly (it defaults to disabled):

testing:
  allow-traffic-grant: true

An authenticated administrator can then credit a regular user without creating a payment order:

POST /v1/admin/traffic/test-grants
Content-Type: application/json

{"userId":8243938201600,"amountGb":10,"reason":"live test"}

The operation updates the user snapshot, appends a test_grant traffic ledger entry, invalidates the Redis balance cache, and writes an operation log. Keep the switch disabled in production after testing.