编译安装
部署成功后, 默认端口为 8094, 访问地址为 http://localhost:8094
Config 配置项 (~/config/config.yaml) 可以使用环境变量进行覆盖, 如 MYSQL_HOST 环境变量可覆盖 mysql.host 配置项
git clone https://github.com/Deeptrain-Community/chatnio.git
cd chatniocd app
npm install -g pnpm
pnpm install
pnpm buildcd ..
go build -o chatnio# e.g. using nohup (you can also use systemd or other service manager)
nohup ./chatnio > output.log & # using nohup to run in background
遇到问题:
1、执行go build -o chatnio时提示webp库有问题,解决方法:
sudo apt-get update
sudo apt-get install libwebp-dev
开启Cgo
export CGO_ENABLED=1
查看是否开启
go env CGO_ENABLED
如果返回值为1则已经开启
2、没有安装gcc,解决方法:安装build-essential,里面包含了gcc编译的相关库
sudo apt update
sudo apt install build-essential
本地chatnio配合docker的mysql和redis调试(不想在本地机器安装mysql和redis)
1、先按照chatnio的GitHub库的docker compose方式部署
2、将docker配置文件docker-compose.yaml修改为对宿主机开放端口(mysq开放为13306,Redis开放为16379),mysql和redis的配置最终如下
services:mysql:image: mysql:latestcontainer_name: dbrestart: alwaysenvironment:MYSQL_ROOT_PASSWORD: rootMYSQL_DATABASE: chatnioMYSQL_USER: chatnioMYSQL_PASSWORD: chatnio123456!TZ: Asia/Shanghai#expose:# - "3306"ports:- "13306:3306" # Map MySQL port from container to hostvolumes:- ./db:/var/lib/mysqlnetworks:- chatnio-networkredis:image: redis:latestcontainer_name: redisrestart: always#expose:# - "6379"ports:- "16379:6379" # Map redis port from container to hostvolumes:- ./redis:/datanetworks:- chatnio-network
3、将chatnio代码git clone到本地,编辑chatnio/config/config.yaml文件,
将mysql端口改为上面的13306,host为127.0.0.1,密码为root,跟docker中的mysql配置一致
将redis端口改为16379,host为127.0.0.1,跟docker中的redis配置一致
mysql:db: chatniohost: 127.0.0.1password: rootport: 3306user: roottls: falseredis:host: 127.0.0.1port: 16379db: 0password: ""
5、启动docker
sudo docker compose up -d
4、编译代码,启动
./chatnio > output.log
访问http://127.0.0.1:8094即可打开chatnio