forked from mtusi2026/mtusi2026lab6
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"log/slog"
|
|
"os"
|
|
|
|
"gitea.privcloud.tech/dizi/mtusi2026lab6/internal/bootstrap"
|
|
"gitea.privcloud.tech/dizi/mtusi2026lab6/internal/logger"
|
|
)
|
|
|
|
func main() {
|
|
appLogger := logger.New()
|
|
if err := run(appLogger, os.Args[1:]); err != nil {
|
|
appLogger.Error("application stopped", "error", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func run(logger *slog.Logger, arguments []string) error {
|
|
if len(arguments) == 0 {
|
|
return bootstrap.RunServer(logger)
|
|
}
|
|
if len(arguments) == 1 && arguments[0] == "migrate" {
|
|
return bootstrap.RunMigrations()
|
|
}
|
|
if len(arguments) == 1 && arguments[0] == "dispatch" {
|
|
return bootstrap.RunDispatcher(logger)
|
|
}
|
|
if len(arguments) == 1 && arguments[0] == "worker" {
|
|
return bootstrap.RunWorker(logger)
|
|
}
|
|
if arguments[0] == "reconcile-attachments" {
|
|
return bootstrap.RunReconciliation(arguments[1:], os.Stdout)
|
|
}
|
|
if arguments[0] == "replay-attachment" {
|
|
return bootstrap.RunAttachmentReplay(arguments[1:], os.Stdout)
|
|
}
|
|
return errors.New("usage: messenger [migrate|dispatch|worker|reconcile-attachments|replay-attachment]")
|
|
}
|