forked from mtusi2026/mtusi2026lab6
chore: import lab5 baseline
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
"gitea.privcloud.tech/dizi/mtusi2026lab5/internal/bootstrap"
|
||||
"gitea.privcloud.tech/dizi/mtusi2026lab5/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]")
|
||||
}
|
||||
Reference in New Issue
Block a user