Files
geo/server/cmd/worker-generate/main.go
T
root 6e6e19cccb feat(schedule-tasks): support auto-publish via media accounts
Replace the legacy target_platform string on schedule tasks with a
workspace-aware auto-publish payload (auto_publish + publish_account_ids
JSONB + cover_asset_url + cover_image_asset_id) and migrate the schema,
sqlc queries, generated models, domain struct, ScheduleTaskService DTOs,
and dispatch worker to round-trip the new fields. PromptRuleGeneration
gains a WithPublishJobService hook so executeGeneration can enqueue an
auto-publish job once the article is ready, and worker-generate wires
the publish-job service in. On the admin-web side, extract
PublishArticleModal's account-card builders into a shared
publish-account-cards module, rebuild GenerateTaskDrawer's schedule
mode around account selection plus a CoverPickerModal, and surface the
new "auto publish" column on ScheduleTaskTab. Shared types and i18n
strings cover the new fields.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 01:32:19 +08:00

125 lines
2.5 KiB
Go

package main
import (
"context"
"log"
"os"
"os/signal"
"syscall"
"github.com/geo-platform/tenant-api/internal/bootstrap"
tenantapp "github.com/geo-platform/tenant-api/internal/tenant/app"
"github.com/geo-platform/tenant-api/internal/tenant/repository"
generateworker "github.com/geo-platform/tenant-api/internal/worker/generate"
)
func main() {
configPath := "configs/config.yaml"
if p := os.Getenv("CONFIG_PATH"); p != "" {
configPath = p
}
app, err := bootstrap.New(configPath)
if err != nil {
log.Fatalf("bootstrap: %v", err)
}
defer app.Close()
generationCfg := app.Config.Generation
generationCfg.StreamEnabled = false
knowledgeSvc := tenantapp.NewKnowledgeService(
app.DB,
app.RetrievalProvider,
app.VectorStore,
app.ObjectStorage,
app.LLM,
app.Logger,
app.Config.Retrieval,
app.Config.LLM,
0,
0,
)
templateSvc := tenantapp.NewTemplateService(
app.DB,
repository.NewCachedTemplateRepository(
repository.NewTemplateRepository(app.DB),
app.Cache,
),
app.LLM,
nil,
knowledgeSvc,
app.GenerationStreams,
generationCfg,
app.Config.LLM.MaxOutputTokens,
).WithCache(app.Cache)
promptRuleSvc := tenantapp.NewPromptRuleGenerationService(
app.DB,
app.LLM,
nil,
knowledgeSvc,
app.GenerationStreams,
generationCfg,
app.Config.LLM.MaxOutputTokens,
).WithCache(app.Cache).WithLogger(app.Logger)
publishJobSvc := tenantapp.NewPublishJobService(
app.DB,
app.RabbitMQ,
app.Redis,
app.Logger,
).WithCache(app.Cache)
promptRuleSvc.WithPublishJobService(publishJobSvc)
imitationSvc := tenantapp.NewArticleImitationService(
app.DB,
app.LLM,
nil,
knowledgeSvc,
app.GenerationStreams,
generationCfg,
app.Config.LLM.MaxOutputTokens,
).WithCache(app.Cache)
kolWorker := generateworker.NewKolGenerationWorker(
app.DB,
app.LLM,
knowledgeSvc,
app.Logger,
generationCfg,
app.Config.LLM.MaxOutputTokens,
).WithCache(app.Cache)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
generateworker.NewArticleGenerationWorker(
app.DB,
app.RabbitMQ,
templateSvc,
promptRuleSvc,
imitationSvc,
kolWorker,
app.Logger,
app.Config.Generation,
).Start(ctx)
generateworker.NewTemplateAssistWorker(
app.RabbitMQ,
templateSvc,
app.Logger,
app.Config.Generation.WorkerConcurrency,
app.Config.Generation.ArticleTimeout,
).Start(ctx)
app.Logger.Info("worker-generate started")
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
cancel()
app.Logger.Info("worker-generate shutting down...")
}