瀏覽代碼

revamp v1

apkipa 2 周之前
父節點
當前提交
bb2e4b3486
共有 5 個文件被更改,包括 129 次插入103 次删除
  1. 3 0
      config/application.yaml
  2. 106 101
      main.go
  3. 3 0
      minio-into-stck-installer/install.sh
  4. 2 1
      package.sh
  5. 15 1
      util/util.go

+ 3 - 0
config/application.yaml

@@ -12,3 +12,6 @@ stck:
   host: "172.31.48.206:9000"
   # host: "localhost:9001"
   table: "tsdb_cpp_dist"
+main:
+  uploadRetryMaxTimes: 20
+  failedRetryDelaySeconds: 5

文件差異過大導致無法顯示
+ 106 - 101
main.go


+ 3 - 0
minio-into-stck-installer/install.sh

@@ -26,3 +26,6 @@ chmod +x /opt/minio-into-stck/minio-into-stck/minio-into-stck
 
 systemctl daemon-reload
 systemctl enable minio-into-stck
+
+systemctl start minio-into-stck
+echo "minio-into-stck已启动"

+ 2 - 1
package.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# set -e
+set -e
 
 cur_date="`date +%Y-%m-%d`"
 ROOT=$(cd `dirname $0`; pwd)
@@ -9,6 +9,7 @@ mkdir -p $ROOT/tmp
 rm -rf $ROOT/tmp/*
 
 # ----- Start build -----
+rm $ROOT/minio-into-stck/minio-into-stck
 CGO_ENABLED=0 go build -o $ROOT/minio-into-stck/minio-into-stck $ROOT/
 
 cp -rf $ROOT/config $ROOT/minio-into-stck/

+ 15 - 1
util/util.go

@@ -1,9 +1,11 @@
 package util
 
 import (
-	"github.com/klauspost/compress/zstd"
 	"os/exec"
 	"strings"
+	"time"
+
+	"github.com/klauspost/compress/zstd"
 )
 
 func ExpandShellString(s string) (string, error) {
@@ -35,3 +37,15 @@ func DecompressZstdBuffer(input []byte) ([]byte, error) {
 	defer decoder.Close()
 	return decoder.DecodeAll(input, nil)
 }
+
+func FmtMyTime(t time.Time) string {
+	return t.Format("2006-01-02 15:04:05.000")
+}
+
+func FmtMyDate(t time.Time) string {
+	return t.Format("2006-01-02")
+}
+
+func LastElem[T any](s []T) T {
+	return s[len(s)-1]
+}