编译安装
部署成功后, 默认端口为 8094, 访问地址为 http://localhost:8094
Config 配置项 (~/config/config.yaml) 可以使用环境变量进行覆盖, 如 MYSQL_HOST 环境变量可覆盖 mysql.host 配置项
git clone https://github.com/Deeptrain-Community/chatnio.git
cd chatnio
cd app
npm install -g pnpm
pnpm install
pnpm build
cd ..
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:latest
container_name: db
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: chatnio
MYSQL_USER: chatnio
MYSQL_PASSWORD: chatnio123456!
TZ: Asia/Shanghai
#expose:
# - "3306"
ports:
- "13306:3306" # Map MySQL port from container to host
volumes:
- ./db:/var/lib/mysql
networks:
- chatnio-network
redis:
image: redis:latest
container_name: redis
restart: always
#expose:
# - "6379"
ports:
- "16379:6379" # Map redis port from container to host
volumes:
- ./redis:/data
networks:
- 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: chatnio
host: 127.0.0.1
password: root
port: 3306
user: root
tls: false
redis:
host: 127.0.0.1
port: 16379
db: 0
password: ""
5、启动docker
sudo docker compose up -d
4、编译代码,启动
./chatnio > output.log
访问http://127.0.0.1:8094即可打开chatnio