beta版, 可以试试部署啦作者都部署了, 还怕什么?
好耶, 是色逼数!
你心里, 没有逼数!
数据 |
---|
图解(硬核) |
---|
![]() |
这些链接可供测试
- https://my.sbchild.top:81/_sbcounter/t1/rw/card
- https://my.sbchild.top:81/_sbcounter/t2/rw/card
- https://my.sbchild.top:81/_sbcounter/t3/rw/card
- https://my.sbchild.top:81/_sbcounter/t4/rw/card
- https://my.sbchild.top:81/_sbcounter/t5/rw/card
记录访问量
-
clone
本项目, 或下载压缩包并解压 -
创建数据库, 目前只支持
postgresql
:
CREATE USER "[用户名]" PASSWORD '[密码]';
CREATE DATABASE [数据库名] OWNER "[用户名]";
进入 [数据库名]
数据库
DROP TABLE public.counter;
CREATE TABLE IF NOT EXISTS public.counter
(
id text COLLATE pg_catalog."default" NOT NULL,
db text COLLATE pg_catalog."default" NOT NULL,
created_at timestamp with time zone,
ip text COLLATE pg_catalog."default" NOT NULL
)
TABLESPACE [表空间, 默认为 pg_default];
ALTER TABLE public.counter
OWNER to "[用户名]";
- 在config目录下, 复制
config.example.toml
到config.toml
, 按需编辑config.toml
:
- 更改数据库地址, 端口号, 名称, 用户名和密码
- 更改监听端口
- 更改
sb-counter
设置
- 编译
- 准备好
golang 1.20+
和gfcli
环境 - 拷贝
manifest/config/config.yaml
到./config.yaml
./build.sh
- 部署
- 确保
sb-counter-bin
和config.yaml
在同一目录下 - 运行
sb-counter-bin
- 使用
- 写入模式, 每次访问都会计数:
http://127.0.0.1:端口号/根目录/用户名/rw/card
- 只读模式, 只能查看, 不会记录:
http://127.0.0.1:端口号/根目录/用户名/ro/card
每个合法的链接都包含一个标识名(称为path
),访问计数器将根据这个标识名来记录访问次数。
此外,每个路径都归属于一个分组,每个分组的访问记录都将存储到数据库中。
如果多个路径属于同一分组,它们的访问计数将会共享。例如,如果两个路径都属于 sbchild-profile 分组,它们的访问计数将会合并计算。
sbcounter:
# 省略
user:
- path: "sbchild" # 这个是路径的名字 例子: http://127.0.0.1:3264/_sbcounter/sbchild/rw/card
db: "sbchild-profile" # 如果上述链接被访问过的话, 访问记录会保存在这个分组(sbchild-profile)里
- path: "testuser" # 具有相同分组的链接, 看到的访问计数是一样的
db: "sbchild-profile"
- path: "aaa" # 这是另一个分组,它和上一个路径互不影响
db: "2"
Apache 2.0
Project Makefile Commands:
make cli
: Install or Update to the latest GoFrame CLI tool.make dao
: Generate go files forEntity/DAO/DO
according to the configuration file fromhack
folder.make service
: Parselogic
folder to generate interface go files intoservice
folder.make image TAG=xxx
: Rundocker build
to build image accordingmanifest/docker
.make image.push TAG=xxx
: Rundocker build
anddocker push
to build and push image accordingmanifest/docker
.make deploy TAG=xxx
: Runkustomize build
to build and deploy deployment to kubernetes server group accordingmanifest/deploy
.