🐛 Fix entry file

This commit is contained in:
LittleSheep 2024-12-14 12:54:12 +08:00
parent e5a1741109
commit b7d7d09eca

View File

@ -2,13 +2,14 @@ package main
import ( import (
"fmt" "fmt"
"os"
"os/signal"
"syscall"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec" "git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
pkg "git.solsynth.dev/hypernet/reader/pkg/internal" pkg "git.solsynth.dev/hypernet/reader/pkg/internal"
"git.solsynth.dev/hypernet/reader/pkg/internal/gap" "git.solsynth.dev/hypernet/reader/pkg/internal/gap"
"github.com/fatih/color" "github.com/fatih/color"
"os"
"os/signal"
"syscall"
"git.solsynth.dev/hypernet/reader/pkg/internal/cache" "git.solsynth.dev/hypernet/reader/pkg/internal/cache"
"git.solsynth.dev/hypernet/reader/pkg/internal/database" "git.solsynth.dev/hypernet/reader/pkg/internal/database"
@ -30,9 +31,9 @@ func init() {
func main() { func main() {
// Booting screen // Booting screen
fmt.Println(color.YellowString(" ____ _ _\n| _ \\ __ _ _ __ ___ _ __ ___| (_)_ __\n| |_) / _` | '_ \\ / _ \\ '__/ __| | | '_ \\\n| __/ (_| | |_) | __/ | | (__| | | |_) |\n|_| \\__,_| .__/ \\___|_| \\___|_|_| .__/\n |_| |_|")) fmt.Println(color.YellowString(" ____ _\n| _ \\ ___ __ _ __| | ___ _ __\n| |_) / _ \\/ _` |/ _` |/ _ \\ '__|\n| _ < __/ (_| | (_| | __/ |\n|_| \\_\\___|\\__,_|\\__,_|\\___|_|"))
fmt.Printf("%s v%s\n", color.New(color.FgHiYellow).Add(color.Bold).Sprintf("Hypernet.Reader"), pkg.AppVersion) fmt.Printf("%s v%s\n", color.New(color.FgHiYellow).Add(color.Bold).Sprintf("Hypernet.Reader"), pkg.AppVersion)
fmt.Printf("The upload service in Hypernet\n") fmt.Printf("The scraper in the Solar Network\n")
color.HiBlack("=====================================================\n") color.HiBlack("=====================================================\n")
// Configure settings // Configure settings
@ -71,20 +72,9 @@ func main() {
log.Fatal().Err(err).Msg("An error occurred when initializing cache.") log.Fatal().Err(err).Msg("An error occurred when initializing cache.")
} }
// Set up some workers
for idx := 0; idx < viper.GetInt("workers.files_deletion"); idx++ {
go services.StartConsumeDeletionTask()
}
for idx := 0; idx < viper.GetInt("workers.files_analyze"); idx++ {
go services.StartConsumeAnalyzeTask()
}
// Configure timed tasks // Configure timed tasks
quartz := cron.New(cron.WithLogger(cron.VerbosePrintfLogger(&log.Logger))) quartz := cron.New(cron.WithLogger(cron.VerbosePrintfLogger(&log.Logger)))
quartz.AddFunc("@every 60m", services.DoAutoDatabaseCleanup) quartz.AddFunc("@every 60m", services.DoAutoDatabaseCleanup)
quartz.AddFunc("@every 60m", services.RunMarkLifecycleDeletionTask)
quartz.AddFunc("@every 60m", services.RunMarkMultipartDeletionTask)
quartz.AddFunc("@midnight", services.RunScheduleDeletionTask)
quartz.Start() quartz.Start()
// Server // Server
@ -93,10 +83,6 @@ func main() {
// Grpc Server // Grpc Server
go grpc.NewGrpc().Listen() go grpc.NewGrpc().Listen()
// Post-boot actions
services.ScanUnanalyzedFileFromDatabase()
services.RunMarkLifecycleDeletionTask()
// Messages // Messages
quit := make(chan os.Signal, 1) quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)