版本更新
This commit is contained in:
parent
4c4e00c507
commit
09df33c3c9
@ -8,6 +8,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
@ -59,20 +60,30 @@ func scheduleDailyTask() {
|
||||
statistics.Statistics()
|
||||
}
|
||||
}
|
||||
|
||||
func getKafkaReader(kafkaURL, topic, groupID string) *kafka.Reader {
|
||||
brokers := strings.Split(kafkaURL, ",")
|
||||
return kafka.NewReader(kafka.ReaderConfig{
|
||||
Brokers: brokers,
|
||||
GroupID: groupID,
|
||||
Topic: topic,
|
||||
MinBytes: 10e3, // 10KB
|
||||
MaxBytes: 10e6, // 10MB
|
||||
})
|
||||
}
|
||||
func comsumer(Game *config.Game) {
|
||||
sqlDb := db.GetContainer(Game.Name)
|
||||
if sqlDb == nil {
|
||||
log.Printf("comsumer db %s not exist \n", Game.Name)
|
||||
return
|
||||
}
|
||||
r := kafka.NewReader(kafka.ReaderConfig{
|
||||
Brokers: []string{"kafka-server:9092"},
|
||||
Topic: Game.Topic,
|
||||
Partition: Game.Partition,
|
||||
MinBytes: 10e3, // 10KB
|
||||
MaxBytes: 10e6, // 10MB
|
||||
})
|
||||
// r := kafka.NewReader(kafka.ReaderConfig{
|
||||
// Brokers: []string{"kafka-server:9092", "kafka-server-2:9092"},
|
||||
// Topic: Game.Topic,
|
||||
// Partition: Game.Partition,
|
||||
// MinBytes: 10e3, // 10KB
|
||||
// MaxBytes: 10e6, // 10MB
|
||||
// })
|
||||
r := getKafkaReader("kafka-server:9092", Game.Topic, "log")
|
||||
defer r.Close()
|
||||
// 设置读取超时时间
|
||||
offset := db.GetOffset(sqlDb)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name pethome.bywaystudios.com;
|
||||
server_name dify.bywaystudios.com;
|
||||
|
||||
# 将 HTTP 请求重定向到 HTTPS
|
||||
location / {
|
||||
@ -10,15 +10,15 @@ server {
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name pethome.bywaystudios.com;
|
||||
server_name dify.bywaystudios.com;
|
||||
|
||||
ssl_certificate /etc/nginx/ssl/pethome.bywaystudios.com.pem;
|
||||
ssl_certificate_key /etc/nginx/ssl/pethome.bywaystudios.com.key;
|
||||
ssl_certificate /etc/nginx/ssl/bywaystudios.com.pem;
|
||||
ssl_certificate_key /etc/nginx/ssl/bywaystudios.com.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:8080;
|
||||
proxy_pass http://localhost:80;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
@ -26,6 +26,6 @@ server {
|
||||
}
|
||||
|
||||
# 可选:配置日志文件
|
||||
access_log /var/log/nginx/pethome_access.log;
|
||||
error_log /var/log/nginx/pethome_error.log;
|
||||
access_log /var/log/nginx/dify_access.log;
|
||||
error_log /var/log/nginx/dify_error.log;
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name admin.bywaystudios.com;
|
||||
server_name gadmin.bywaystudios.com;
|
||||
|
||||
# 将 HTTP 请求重定向到 HTTPS
|
||||
location / {
|
||||
location /api {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
31
nginx/zabbix.conf
Normal file
31
nginx/zabbix.conf
Normal file
@ -0,0 +1,31 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name zabbix.bywaystudios.com;
|
||||
|
||||
# 将 HTTP 请求重定向到 HTTPS
|
||||
location /api {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name zabbix.bywaystudios.com;
|
||||
|
||||
ssl_certificate /etc/nginx/ssl/bywaystudios.com.pem;
|
||||
ssl_certificate_key /etc/nginx/ssl/bywaystudios.com.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:8081;
|
||||
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 X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# 可选:配置日志文件
|
||||
access_log /var/log/nginx/zabbix_access.log;
|
||||
error_log /var/log/nginx/zabbix_error.log;
|
||||
}
|
||||
@ -28,6 +28,10 @@
|
||||
- name: pack.sh
|
||||
shell: sh /data/admin_backend/release/pack.sh
|
||||
delegate_to: localhost
|
||||
- name: copy template
|
||||
copy:
|
||||
src: /data/admin_backend/template/
|
||||
dest: /usr/local/admin/backend/template
|
||||
- name: copy tar
|
||||
copy:
|
||||
src: /data/admin_backend/release/backend
|
||||
|
||||
29
playbook/zabbix.yml
Normal file
29
playbook/zabbix.yml
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
- name: Deploy zabbix
|
||||
hosts: gitea
|
||||
remote_user: root
|
||||
|
||||
tasks:
|
||||
|
||||
- name: archive docker-compose
|
||||
archive:
|
||||
path: /data/zabbix-docker-remote/
|
||||
dest: /data/zabbix.tar
|
||||
format: tar
|
||||
delegate_to: localhost
|
||||
- name: copy tar
|
||||
copy:
|
||||
src: /data/zabbix.tar
|
||||
dest: /data/zabbix.tar
|
||||
- name: remove docker-compose
|
||||
shell: rm -rf /data/zabbix.tar
|
||||
delegate_to: localhost
|
||||
|
||||
- name: mkdir
|
||||
shell: mkdir -p /data/zabbix-docker
|
||||
|
||||
- name: unarchive config
|
||||
unarchive:
|
||||
src: /data/zabbix.tar
|
||||
dest: //data/zabbix-docker/
|
||||
remote_src: yes
|
||||
@ -1,5 +1,5 @@
|
||||
cd /usr/local
|
||||
wget https://go.dev/dl/go1.23.4.linux-386.tar.gz
|
||||
tar -C /usr/local -xzf go1.23.4.src.tar.gz
|
||||
tar -C /usr/local -xzf go1.23.4.linux-386.tar.gz
|
||||
echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
|
||||
echo "export GOPATH=$HOME/go" >> /etc/profile
|
||||
|
||||
41
zabbix/script/error.js
Normal file
41
zabbix/script/error.js
Normal file
@ -0,0 +1,41 @@
|
||||
try {
|
||||
var params = JSON.parse(value);
|
||||
var response;
|
||||
request = new HttpRequest(),
|
||||
data = {
|
||||
"msg_type": "interactive",
|
||||
"card": {
|
||||
"type": "template",
|
||||
"data": {
|
||||
"template_id": "AAqBcOkbPmfUZ",
|
||||
"template_version_name": "1.0.3",
|
||||
"template_variable": {
|
||||
"appName": "Zabbix",
|
||||
"msg": params.Message,
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
request.addHeader('Content-Type: application/json');
|
||||
|
||||
Zabbix.log(4, '[ Feishu Webhook ] Sending request.');
|
||||
|
||||
response = request.post("https://open.feishu.cn/open-apis/bot/v2/hook/48944500-477a-4647-a7e0-c56c43bee263", JSON.stringify(data));
|
||||
|
||||
if (request.getStatus() < 200 || request.getStatus() >= 300) {
|
||||
var message = 'Request failed with status code ' + request.getStatus();
|
||||
|
||||
if (response) {
|
||||
message += ': ' + response;
|
||||
}
|
||||
throw message + '. Check debug log for more information.';
|
||||
}
|
||||
|
||||
|
||||
return 'OK';
|
||||
}
|
||||
catch (error) {
|
||||
Zabbix.log(3, '[ BrevisOne Webhook ] ERROR: ' + error);
|
||||
throw 'Sending failed: ' + error;
|
||||
}
|
||||
40
zabbix/script/info.js
Normal file
40
zabbix/script/info.js
Normal file
@ -0,0 +1,40 @@
|
||||
try {
|
||||
var params = JSON.parse(value);
|
||||
var response;
|
||||
request = new HttpRequest(),
|
||||
data = {
|
||||
"msg_type": "interactive",
|
||||
"card": {
|
||||
"type": "template",
|
||||
"data": {
|
||||
"template_id": "AAqB1vicX1mY4",
|
||||
"template_version_name": "1.0.0",
|
||||
"template_variable": {
|
||||
"appName": "Zabbix",
|
||||
"msg": params.Messagae,
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
request.addHeader('Content-Type: application/json');
|
||||
|
||||
Zabbix.log(4, '[ Feishu Webhook ] Sending request.');
|
||||
|
||||
response = request.post("https://open.feishu.cn/open-apis/bot/v2/hook/64bad1f3-3a41-4dca-9037-399067ffb252", JSON.stringify(data));
|
||||
|
||||
if (request.getStatus() < 200 || request.getStatus() >= 300) {
|
||||
var message = 'Request failed with status code ' + request.getStatus();
|
||||
|
||||
if (response) {
|
||||
message += ': ' + response;
|
||||
}
|
||||
throw message + '. Check debug log for more information.';
|
||||
}
|
||||
|
||||
return 'OK';
|
||||
}
|
||||
catch (error) {
|
||||
Zabbix.log(3, '[ BrevisOne Webhook ] ERROR: ' + error);
|
||||
throw 'Sending failed: ' + error;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user