Skip to content

Commit 060e3e7

Browse files
committed
fix: Readme文档
1 parent e3c00a7 commit 060e3e7

File tree

2 files changed

+75
-18
lines changed

2 files changed

+75
-18
lines changed

README-zh.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
### file-watcher 文件监听器
2+
### 介绍
3+
`file-watcher`是基于golang实现的文件监听器,当文件有任何变更时,会产生事件,支持`Create` `Rename` `Write` `Remove`事件,并生成对应的k8s事件。
4+
![](https://github.com/studyplace-io/file-watcher/blob/main/image/%E6%97%A0%E6%A0%87%E9%A2%98-2023-08-10-2343.png?raw=true)
5+
### 项目功能
6+
- 自定义监听多个文件(使用空格分隔)
7+
- 生成k8s event(事件)(`Create` `Rename` `Write` `Remove`事件)
8+
9+
### 项目启动
10+
- 使用方法
11+
```bash
12+
# go run cmd/main.go <文件路径1> <文件路径2>
13+
➜ file-watcher git:(main) go run cmd/main.go test.txt test11.yaml
14+
I0910 11:55:06.031217 55434 init_k8s_config.go:33] run outside the cluster
15+
I0910 11:55:06.033137 55434 watcher.go:36] Start watching files: /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test.txt
16+
I0910 11:55:06.033161 55434 watcher.go:36] Start watching files: /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test11.yaml
17+
2023/09/10 11:55:09 File modified: /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test11.yaml
18+
File /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test11.yaml Modified
19+
I0910 11:55:09.641927 55434 event_generator.go:100] Event generated successfully: test11.yaml-2023-09-10 11:55:09.607918 +0800 CST m=+3.591877917
20+
2023/09/10 11:55:15 File modified: /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test.txt
21+
File /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test.txt Modified
22+
I0910 11:55:15.879443 55434 event_generator.go:100] Event generated successfully: test.txt-2023-09-10 11:55:15.874743 +0800 CST m=+9.858852501
23+
2023/09/10 11:55:34 File renamed: /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test11.yaml
24+
File /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test11.yaml Renamed
25+
I0910 11:55:34.411631 55434 event_generator.go:100] Event generated successfully: test11.yaml-2023-09-10 11:55:34.40578 +0800 CST m=+28.3903301
26+
27+
```
28+
29+
- 生成对应的event事件类型
30+
```bash
31+
➜ .kube kubectl get event
32+
LAST SEEN TYPE REASON OBJECT MESSAGE
33+
58m Modified Watch file change file/test.txt File /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test.txt Modified
34+
55m Modified Watch file change file/test.txt File /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test.txt Modified
35+
51m Modified Watch file change file/test.txt File /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test.txt Modified
36+
26s Modified Watch file change file/test.txt File /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test.txt Modified
37+
32s Modified Watch file change file/test11.yaml File /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test11.yaml Modified
38+
7s Renamed Watch file change file/test11.yaml File /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test11.yaml Renamed
39+
```
40+
41+
### 部署方式
42+
目前支持 二进制、docker部署、k8s 集群部署
43+
- docker 镜像
44+
```bash
45+
docker build -t file-watcher:v1 .
46+
```
47+
48+
```bash
49+
[root@VM-0-16-centos yaml]# cd ..
50+
[root@VM-0-16-centos file-watcher]# kubectl apply -f yaml/rbac.yaml
51+
serviceaccount/file-watcher-sa unchanged
52+
clusterrole.rbac.authorization.k8s.io/file-watcher-clusterrole unchanged
53+
clusterrolebinding.rbac.authorization.k8s.io/file-watcher-ClusterRoleBinding unchanged
54+
55+
[root@VM-0-16-centos file-watcher]# kubectl apply -f yaml/deploy.yaml
56+
deployment.apps/file-watcher unchanged
57+
```
58+
59+
注:yaml/deploy.yaml在部署时,**需要特别注意挂载问题**

README.md

+16-18
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
### file-watcher 文件监听器
2-
3-
### 介绍
4-
`file-watcher`是基于golang实现的文件监听器,当文件有任何变更时,会产生事件,支持`Create` `Rename` `Write` `Remove`事件,并生成对应的k8s事件。
1+
### file-watcher
2+
<a href="./README.md">English</a> | <a href="./README-zh.md">简体中文</a>
3+
### Introduction
4+
`file-watcher` is a file listener implemented based on golang. When there are any changes to the file, an event will be generated. It supports `Create` `Rename` `Write` `Remove` events and generates corresponding k8s events.
55
![](https://github.com/studyplace-io/file-watcher/blob/main/image/%E6%97%A0%E6%A0%87%E9%A2%98-2023-08-10-2343.png?raw=true)
6-
### 项目功能
7-
- 自定义监听多个文件(使用空格分隔)
8-
- 生成k8s event(事件)(`Create` `Rename` `Write` `Remove`事件)
9-
6+
### Project support
7+
- Customize monitoring of multiple files (separated by spaces)
8+
- Generate k8s event (event)(`Create` `Rename` `Write` `Remove`event)
109

11-
### 项目启动
12-
- 使用方法
10+
### start up
11+
- usage
1312
```bash
14-
# go run cmd/main.go <文件路径1> <文件路径2>
13+
# go run cmd/main.go <filepath1> <filepath2>
1514
➜ file-watcher git:(main) go run cmd/main.go test.txt test11.yaml
1615
I0910 11:55:06.031217 55434 init_k8s_config.go:33] run outside the cluster
1716
I0910 11:55:06.033137 55434 watcher.go:36] Start watching files: /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test.txt
@@ -28,7 +27,7 @@ I0910 11:55:34.411631 55434 event_generator.go:100] Event generated successful
2827

2928
```
3029

31-
- 生成对应的event事件类型
30+
- Generate the event type
3231
```bash
3332
➜ .kube kubectl get event
3433
LAST SEEN TYPE REASON OBJECT MESSAGE
@@ -38,16 +37,15 @@ LAST SEEN TYPE REASON OBJECT MESSAGE
3837
26s Modified Watch file change file/test.txt File /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test.txt Modified
3938
32s Modified Watch file change file/test11.yaml File /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test11.yaml Modified
4039
7s Renamed Watch file change file/test11.yaml File /Users/zhenyu.jiang/go/src/golanglearning/new_project/file-watcher/test11.yaml Renamed
41-
4240
```
4341

44-
### 部署方式
45-
目前支持 二进制、docker部署、k8s 集群部署
46-
- docker 镜像
42+
### Deploy
43+
Currently supports binary, docker deployment, k8s cluster deployment
44+
- docker image
4745
```bash
4846
docker build -t file-watcher:v1 .
4947
```
50-
48+
- k8s cluster
5149
```bash
5250
[root@VM-0-16-centos yaml]# cd ..
5351
[root@VM-0-16-centos file-watcher]# kubectl apply -f yaml/rbac.yaml
@@ -59,4 +57,4 @@ clusterrolebinding.rbac.authorization.k8s.io/file-watcher-ClusterRoleBinding unc
5957
deployment.apps/file-watcher unchanged
6058
```
6159

62-
注:yaml/deploy.yaml在部署时,**需要特别注意挂载问题**
60+
P.S.:When deploying yaml/deploy.yaml, you need to pay special attention to **the mounting problem**

0 commit comments

Comments
 (0)