/yurikoto-api-v1

Yurikoto第一版API实现,基于go-gin

Primary LanguageGoGNU Affero General Public License v3.0AGPL-3.0

Yurikoto第一版API实现(基于Golang)

使用或自部署本代码请严格遵守AGPL-3.0协议。本仓库代码可供学习使用,但Yurikoto提供的壁纸、台词资源严禁商用

Open Source Helpers Go Report Card Maintainability FOSSA Status

简介

通过go-gin实现的Yurikoto第一版API,如果您有任何建议或改进想法,欢迎提交issue或pr。

Yurikoto主页

自部署指南

环境

以下为Yurikoto官方使用的环境 CentOS 8.2 Nginx 1.17 Go 1.15.7 (服务端可不需要) MySQL 5.7 Redis 6.0.10

数据库

本项目使用gorm进行数据库操作,无需提前创建表等。如需要使用Yurikoto官方数据库,请提交issue并留下您的邮箱以获取数据库备份。

配置文件

根据文件内提示修改config.template.ini并重命名为config.ini

编译

go mod download
SET GOOS=linux
SET GOARCH=amd64
go build

执行上述命令后项目目录会出现可执行文件yurikoto-api-go-v1

运行

将可执行文件与config.inifavicon.ico上传到服务器。在lib/systemd/system下创建yurikoto-api-v1.service,内容如下:

[Unit]
Description=Yurikoto API V1 Service
After=network.target

[Service]
Type=simple
Restart=on-failure
RestartSec=5s
ExecStart=/path/yurikoto-api-go-v1 -c /path/


[Install]
WantedBy=multi-user.target

并将path替换为可执行文件所在目录(ExecStart末尾斜杠需保留)。执行:

systemctl enable yurikoto-api-v1
systemctl start yurikoto-api-v1
systemctl status yurikoto-api-v1

若显示"active"字样,则说明部署成功。

反向代理

location /
{
    proxy_pass http://127.0.0.1:3417;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    
    add_header Access-Control-Allow-Origin *;
    add_header X-Cache $upstream_cache_status;
    
    #Set Nginx Cache
    
    add_header Cache-Control no-cache;
    expires 12h;
}