MCPcopy
hub / github.com/QuantumNous/new-api / InitResources

Function InitResources

main.go:259–335  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

257}
258
259func InitResources() error {
260 // Initialize resources here if needed
261 // This is a placeholder function for future resource initialization
262 err := godotenv.Load(".env")
263 if err != nil {
264 if common.DebugEnabled {
265 common.SysLog("No .env file found, using default environment variables. If needed, please create a .env file and set the relevant variables.")
266 }
267 }
268
269 // 加载环境变量
270 common.InitEnv()
271
272 logger.SetupLogger()
273
274 // Initialize model settings
275 ratio_setting.InitRatioSettings()
276
277 service.InitHttpClient()
278
279 service.InitTokenEncoders()
280
281 // Initialize SQL Database
282 err = model.InitDB()
283 if err != nil {
284 common.FatalLog("failed to initialize database: " + err.Error())
285 return err
286 }
287
288 model.CheckSetup()
289
290 // Initialize options, should after model.InitDB()
291 model.InitOptionMap()
292
293 // 清理旧的磁盘缓存文件
294 common.CleanupOldCacheFiles()
295
296 // 初始化模型
297 model.GetPricing()
298
299 // Initialize SQL Database
300 err = model.InitLogDB()
301 if err != nil {
302 return err
303 }
304
305 // Initialize Redis
306 err = common.InitRedisClient()
307 if err != nil {
308 return err
309 }
310
311 perfmetrics.Init()
312
313 // 启动系统监控
314 common.StartSystemMonitor()
315
316 // Initialize i18n

Callers 1

mainFunction · 0.85

Calls 15

SysLogFunction · 0.92
InitEnvFunction · 0.92
SetupLoggerFunction · 0.92
InitRatioSettingsFunction · 0.92
InitHttpClientFunction · 0.92
InitTokenEncodersFunction · 0.92
InitDBFunction · 0.92
FatalLogFunction · 0.92
CheckSetupFunction · 0.92
InitOptionMapFunction · 0.92
CleanupOldCacheFilesFunction · 0.92
GetPricingFunction · 0.92

Tested by

no test coverage detected