forked from mtusi2026/mtusi2026lab7
40 lines
1022 B
Go
40 lines
1022 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
|
|
"gitea.privcloud.tech/dizi/mtusi2026lab7/internal/bootstrap"
|
|
"gitea.privcloud.tech/dizi/mtusi2026lab7/internal/logger"
|
|
)
|
|
|
|
func main() {
|
|
appLogger := logger.New()
|
|
if err := run(os.Args[1:]); err != nil {
|
|
appLogger.Error("application stopped", "error", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func run(arguments []string) error {
|
|
if len(arguments) == 0 {
|
|
return bootstrap.RunServer()
|
|
}
|
|
if len(arguments) == 1 && arguments[0] == "migrate" {
|
|
return bootstrap.RunMigrations()
|
|
}
|
|
if len(arguments) == 1 && arguments[0] == "dispatch" {
|
|
return bootstrap.RunDispatcher()
|
|
}
|
|
if len(arguments) == 1 && arguments[0] == "worker" {
|
|
return bootstrap.RunWorker()
|
|
}
|
|
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]")
|
|
}
|