2024-11-22 16:41:04 +08:00
|
|
|
// entry function
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"flag"
|
2025-12-12 11:01:18 +08:00
|
|
|
"log"
|
2025-12-25 17:17:20 +08:00
|
|
|
|
refactor: move ModelRT startup assembly into Wire app package
- add app package with Wire providers, injector declaration, and generated
InitializeApp implementation
- move config loading, logger/tracer setup, database, redis, pool, RabbitMQ,
task worker, router, and HTTP server construction out of main.go
- preserve startup warmup, background publishers, task worker launch, and
graceful shutdown behavior behind App methods
- add github.com/google/wire dependency for generated dependency injection
2026-06-24 15:18:27 +08:00
|
|
|
"modelRT/app"
|
2025-12-19 17:33:12 +08:00
|
|
|
|
|
|
|
|
_ "modelRT/docs"
|
2024-11-22 16:41:04 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
2025-10-17 17:10:10 +08:00
|
|
|
modelRTConfigDir = flag.String("modelRT_config_dir", "./configs", "config file dir of model runtime service")
|
2024-11-22 16:41:04 +08:00
|
|
|
modelRTConfigName = flag.String("modelRT_config_name", "config", "config file name of model runtime service")
|
|
|
|
|
modelRTConfigType = flag.String("modelRT_config_type", "yaml", "config file type of model runtime service")
|
|
|
|
|
)
|
|
|
|
|
|
2025-10-20 15:06:23 +08:00
|
|
|
// @title ModelRT 实时模型服务 API 文档
|
|
|
|
|
// @version 1.0
|
|
|
|
|
// @description 实时数据计算和模型运行服务的 API 服务
|
|
|
|
|
//
|
|
|
|
|
// @contact.name douxu
|
|
|
|
|
// TODO 修改支持的文档地址
|
|
|
|
|
// @contact.url http://www.swagger.io/support
|
|
|
|
|
// @contact.email douxu@clea.com.cn
|
|
|
|
|
//
|
|
|
|
|
// @license.name Apache 2.0
|
|
|
|
|
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
|
|
|
|
//
|
|
|
|
|
// @host localhost:8080
|
|
|
|
|
// @BasePath /api/v1
|
2026-04-01 17:15:33 +08:00
|
|
|
|
2024-11-22 16:41:04 +08:00
|
|
|
func main() {
|
|
|
|
|
flag.Parse()
|
|
|
|
|
|
refactor: move ModelRT startup assembly into Wire app package
- add app package with Wire providers, injector declaration, and generated
InitializeApp implementation
- move config loading, logger/tracer setup, database, redis, pool, RabbitMQ,
task worker, router, and HTTP server construction out of main.go
- preserve startup warmup, background publishers, task worker launch, and
graceful shutdown behavior behind App methods
- add github.com/google/wire dependency for generated dependency injection
2026-06-24 15:18:27 +08:00
|
|
|
ctx := context.Background()
|
2025-10-15 17:08:32 +08:00
|
|
|
|
refactor: move ModelRT startup assembly into Wire app package
- add app package with Wire providers, injector declaration, and generated
InitializeApp implementation
- move config loading, logger/tracer setup, database, redis, pool, RabbitMQ,
task worker, router, and HTTP server construction out of main.go
- preserve startup warmup, background publishers, task worker launch, and
graceful shutdown behavior behind App methods
- add github.com/google/wire dependency for generated dependency injection
2026-06-24 15:18:27 +08:00
|
|
|
cli := app.CLIArgs{
|
|
|
|
|
ConfigDir: *modelRTConfigDir,
|
|
|
|
|
ConfigName: *modelRTConfigName,
|
|
|
|
|
ConfigType: *modelRTConfigType,
|
2024-12-18 16:25:49 +08:00
|
|
|
}
|
|
|
|
|
|
refactor: move ModelRT startup assembly into Wire app package
- add app package with Wire providers, injector declaration, and generated
InitializeApp implementation
- move config loading, logger/tracer setup, database, redis, pool, RabbitMQ,
task worker, router, and HTTP server construction out of main.go
- preserve startup warmup, background publishers, task worker launch, and
graceful shutdown behavior behind App methods
- add github.com/google/wire dependency for generated dependency injection
2026-06-24 15:18:27 +08:00
|
|
|
application, cleanup, err := app.InitializeApp(ctx, cli)
|
2026-04-01 17:15:33 +08:00
|
|
|
if err != nil {
|
refactor: move ModelRT startup assembly into Wire app package
- add app package with Wire providers, injector declaration, and generated
InitializeApp implementation
- move config loading, logger/tracer setup, database, redis, pool, RabbitMQ,
task worker, router, and HTTP server construction out of main.go
- preserve startup warmup, background publishers, task worker launch, and
graceful shutdown behavior behind App methods
- add github.com/google/wire dependency for generated dependency injection
2026-06-24 15:18:27 +08:00
|
|
|
log.Fatalf("failed to initialize app: %v", err)
|
2026-04-01 17:15:33 +08:00
|
|
|
}
|
refactor: move ModelRT startup assembly into Wire app package
- add app package with Wire providers, injector declaration, and generated
InitializeApp implementation
- move config loading, logger/tracer setup, database, redis, pool, RabbitMQ,
task worker, router, and HTTP server construction out of main.go
- preserve startup warmup, background publishers, task worker launch, and
graceful shutdown behavior behind App methods
- add github.com/google/wire dependency for generated dependency injection
2026-06-24 15:18:27 +08:00
|
|
|
defer cleanup()
|
2026-04-01 17:15:33 +08:00
|
|
|
|
refactor: move ModelRT startup assembly into Wire app package
- add app package with Wire providers, injector declaration, and generated
InitializeApp implementation
- move config loading, logger/tracer setup, database, redis, pool, RabbitMQ,
task worker, router, and HTTP server construction out of main.go
- preserve startup warmup, background publishers, task worker launch, and
graceful shutdown behavior behind App methods
- add github.com/google/wire dependency for generated dependency injection
2026-06-24 15:18:27 +08:00
|
|
|
// warm caches from postgres, then start background publishers/worker
|
|
|
|
|
application.Warmup(ctx)
|
|
|
|
|
application.StartBackground(ctx)
|
2025-12-22 17:38:15 +08:00
|
|
|
|
refactor: move ModelRT startup assembly into Wire app package
- add app package with Wire providers, injector declaration, and generated
InitializeApp implementation
- move config loading, logger/tracer setup, database, redis, pool, RabbitMQ,
task worker, router, and HTTP server construction out of main.go
- preserve startup warmup, background publishers, task worker launch, and
graceful shutdown behavior behind App methods
- add github.com/google/wire dependency for generated dependency injection
2026-06-24 15:18:27 +08:00
|
|
|
// blocks until the server is shut down
|
|
|
|
|
application.Run(ctx)
|
2024-11-22 16:41:04 +08:00
|
|
|
}
|