public IActionResult Connect() { string workerof = AppCommandResolver.GetTargetMasterName(); string encodeKey = Request.Headers["sm_connection"].FirstOrDefault(); if (string.IsNullOrEmpty(workerof) || string.IsNullOrEmpty(encodeKey)) { _logger.LogWarning("connect failed! workerof or encodekey is null..."); return(BadRequest("Unauthorized Connection.")); } if (!Core.Common.SecurityHelper.MD5(workerof).Equals(encodeKey)) { _logger.LogWarning("connect failed! encodekey is unvalid, wokerof:{0}, encodekey:{1}", workerof, encodeKey); return(BadRequest("Unauthorized Connection.")); } string workerName = Request.Headers["sm_nameto"].FirstOrDefault(); var node = _db.ServerNodes.FirstOrDefault(x => x.NodeName == workerName); if (node == null) { _logger.LogWarning("connect failed! unkown worker name:{0}...", workerName); return(BadRequest("Unkown Worker Name.")); } Core.ConfigurationCache.SetNode(node); string secret = Guid.NewGuid().ToString("n"); QuartzManager.AccessSecret = secret; _logger.LogInformation("successfully connected to {0}!", workerof); LogHelper.Info($"与{workerof}连接成功~"); return(Ok(secret)); }
private void OnStarted() { _logger.LogInformation("Hosted service OnStarted"); string pluginBasePath = ConfigurationCache.PluginPathPrefix.ToPhysicalPath(); if (!System.IO.Directory.Exists(pluginBasePath)) { System.IO.Directory.CreateDirectory(pluginBasePath); } //加载全局缓存 ConfigurationCache.Reload(); //初始化日志管理器 Core.Log.LogManager.Init(); //判断是否要自动根据配置文件注册节点信息 if (AppCommandResolver.IsAutoRegister()) { _logger.LogInformation("enabled auto register..."); //设置节点信息 ConfigurationCache.SetNode(_configuration); //初始化Quartz Common.QuartzManager.InitScheduler().Wait(); //初始化延时队列容器 DelayedTask.DelayPlanManager.Init(); } }
private void OnStarted() { _logger.LogInformation("Hosted service OnStarted"); //加载全局缓存 ConfigurationCache.Reload(); //初始化日志管理器 Core.Log.LogManager.Init(); //判断是否要自动根据配置文件注册节点信息 if (AppCommandResolver.IsAutoRegister()) { _logger.LogInformation("enabled auto register..."); //设置节点信息 ConfigurationCache.SetNode(_configuration); //初始化Quartz Common.QuartzManager.InitScheduler().Wait(); } }