Skip to content

Commit 314318c

Browse files
committed
update README
1 parent fa52da3 commit 314318c

File tree

3 files changed

+104
-30
lines changed

3 files changed

+104
-30
lines changed

README-EN.md

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,52 +24,90 @@ pip install -r requirements.txt
2424

2525
### 2. Configure the Application
2626

27-
Edit the `config.json` file to set up your GitHub token, notification settings, subscription file, and update interval:
27+
Edit the `config.json` file to set up your GitHub token, Email settings(e.g.Tencent Exmail), subscription file, and update settings:
28+
2829

2930
```json
3031
{
3132
"github_token": "your_github_token",
32-
"notification_settings": {
33-
"email": "[email protected]",
34-
"slack_webhook_url": "your_slack_webhook_url"
33+
"email": {
34+
"smtp_server": "smtp.exmail.qq.com",
35+
"smtp_port": 465,
36+
"from": "[email protected]",
37+
"password": "your_email_password",
38+
3539
},
40+
"slack_webhook_url": "your_slack_webhook_url",
3641
"subscriptions_file": "subscriptions.json",
37-
"update_interval": 86400
42+
"github_progress_frequency_days": 1,
43+
"github_progress_execution_time":"08:00"
3844
}
45+
46+
```
47+
**For security reasons:** It is recommended to configure the GitHub Token and Email Password using environment variables to avoid storing sensitive information in plain text, as shown below:
48+
49+
```shell
50+
# GitHub
51+
export GITHUB_TOKEN="github_pat_xxx"
52+
# Email
53+
export EMAIL_PASSWORD="password"
3954
```
4055

4156
### 3. How to Run
4257

43-
GitHub Sentinel supports three different ways to run the application:
58+
GitHub Sentinel supports the following three modes of operation:
4459

4560
#### A. Run as a Command-Line Tool
4661

47-
You can run the application interactively from the command line:
62+
You can interactively run the application from the command line:
4863

4964
```sh
5065
python src/command_tool.py
5166
```
5267

53-
In this mode, you can manually input commands to manage subscriptions, retrieve updates, and generate reports.
68+
In this mode, you can manually enter commands to manage subscriptions, retrieve updates, and generate reports.
5469

55-
#### B. Run as a Daemon Process with Scheduler
70+
#### B. Run as a Background Service
5671

57-
To run the application as a background service (daemon) that regularly checks for updates:
72+
To run the application as a background service (daemon), it will automatically update according to the configured schedule.
5873

59-
1. Ensure you have the `python-daemon` package installed:
74+
You can use the daemon management script [daemon_control.sh](daemon_control.sh) to start, check the status, stop, and restart:
75+
76+
1. Start the service:
6077

6178
```sh
62-
pip install python-daemon
79+
$ ./daemon_control.sh start
80+
Starting DaemonProcess...
81+
DaemonProcess started.
6382
```
6483

65-
2. Launch the daemon process:
84+
- This will launch [./src/daemon_process.py], generating reports periodically as set in `config.json`, and sending emails.
85+
- Service logs will be saved to `logs/DaemonProcess.log`, with historical logs also appended to `logs/app.log`.
86+
87+
2. Check the service status:
6688

6789
```sh
68-
nohup python3 src/daemon_process.py > logs/daemon_process.log 2>&1 &
90+
$ ./daemon_control.sh status
91+
DaemonProcess is running.
6992
```
7093

71-
- This will start the scheduler in the background, checking for updates at the interval specified in your `config.json`.
72-
- Logs will be saved to the `logs/daemon_process.log` file.
94+
3. Stop the service:
95+
96+
```sh
97+
$ ./daemon_control.sh stop
98+
Stopping DaemonProcess...
99+
DaemonProcess stopped.
100+
```
101+
102+
4. Restart the service:
103+
104+
```sh
105+
$ ./daemon_control.sh restart
106+
Stopping DaemonProcess...
107+
DaemonProcess stopped.
108+
Starting DaemonProcess...
109+
DaemonProcess started.
110+
```
73111

74112
#### C. Run as a Gradio Server
75113

README.md

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,32 @@ pip install -r requirements.txt
2424

2525
### 2. 配置应用
2626

27-
编辑 `config.json` 文件,以设置您的 GitHub 令牌、通知设置、订阅文件和更新间隔
27+
编辑 `config.json` 文件,以设置您的 GitHub Token、Email 设置(以腾讯企微邮箱为例)、订阅文件和更新设置
2828

2929
```json
3030
{
3131
"github_token": "your_github_token",
32-
"notification_settings": {
33-
"email": "[email protected]",
34-
"slack_webhook_url": "your_slack_webhook_url"
32+
"email": {
33+
"smtp_server": "smtp.exmail.qq.com",
34+
"smtp_port": 465,
35+
"from": "[email protected]",
36+
"password": "your_email_password",
37+
3538
},
39+
"slack_webhook_url": "your_slack_webhook_url",
3640
"subscriptions_file": "subscriptions.json",
37-
"update_interval": 86400
41+
"github_progress_frequency_days": 1,
42+
"github_progress_execution_time":"08:00"
3843
}
3944
```
45+
**出于安全考虑:** GitHub Token 和 Email Password 的设置均支持使用环境变量进行配置,以避免明文配置重要信息,如下所示:
46+
47+
```shell
48+
# Github
49+
export GITHUB_TOKEN="github_pat_xxx"
50+
# Email
51+
export EMAIL_PASSWORD="password"
52+
```
4053

4154
### 3. 如何运行
4255

@@ -52,25 +65,48 @@ python src/command_tool.py
5265

5366
在此模式下,您可以手动输入命令来管理订阅、检索更新和生成报告。
5467

55-
#### B. 作为后台进程运行(带调度器)
68+
#### B. 作为后台服务运行
69+
70+
要将该应用作为后台服务(守护进程)运行,它将根据相关配置定期自动更新。
71+
72+
您可以直接使用守护进程管理脚本 [daemon_control.sh](daemon_control.sh) 来启动、查询状态、关闭和重启:
73+
74+
1. 启动服务:
5675

57-
要将该应用作为后台服务(守护进程)运行,它将定期检查更新:
76+
```sh
77+
$ ./daemon_control.sh start
78+
Starting DaemonProcess...
79+
DaemonProcess started.
80+
```
81+
82+
- 这将启动[./src/daemon_process.py],按照 `config.json` 中设置的更新频率和时间点定期生成报告,并发送邮件。
83+
- 本次服务日志将保存到 `logs/DaemonProcess.log` 文件中。同时,历史累计日志也将同步追加到 `logs/app.log` 日志文件中。
5884

59-
1. 确保您已安装 `python-daemon`
85+
2. 查询服务状态
6086

6187
```sh
62-
pip install python-daemon
88+
$ ./daemon_control.sh status
89+
DaemonProcess is running.
6390
```
6491

65-
2. 启动后台进程
92+
3. 关闭服务
6693

6794
```sh
68-
nohup python3 src/daemon_process.py > logs/daemon_process.log 2>&1 &
95+
$ ./daemon_control.sh stop
96+
Stopping DaemonProcess...
97+
DaemonProcess stopped.
6998
```
7099

71-
- 这将启动后台调度器,按照 `config.json` 中指定的间隔定期检查更新。
72-
- 日志将保存到 `logs/daemon_process.log` 文件中。
100+
4. 重启服务:
73101

102+
```sh
103+
$ ./daemon_control.sh restart
104+
Stopping DaemonProcess...
105+
DaemonProcess stopped.
106+
Starting DaemonProcess...
107+
DaemonProcess started.
108+
```
109+
74110
#### C. 作为 Gradio 服务器运行
75111

76112
要使用 Gradio 界面运行应用,允许用户通过 Web 界面与该工具交互:

daemon_control.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PID_FILE="./run/$DAEMON_NAME.pid"
88

99
start() {
1010
echo "Starting $DAEMON_NAME..."
11-
python3 $DAEMON_PATH > $LOG_FILE 2>&1 &
11+
nohup python3 $DAEMON_PATH > $LOG_FILE 2>&1 &
1212
echo $! > $PID_FILE
1313
echo "$DAEMON_NAME started."
1414
}

0 commit comments

Comments
 (0)