private void Start(IConsulClient consulClient, ILoggerFactory logerFactory) { if (ServiceInfo != null) { var configFilePath = Path.Combine(ServiceInfo.Location, "config.json"); ConfigurationManager.Setup(configFilePath, logerFactory); ServiceResourceManager.Load(); CacheProviderFactory.Init(); var lifetime = GetMicroserviceLifetime(); lifetime?.Start(); ServiceInfo.StartedAt = DateTime.Now; } consulClient.RegisterMicroServiceAsync(ServiceInfo); }
private static void Load(string configFilePath) { var content = File.ReadAllText(configFilePath); Settings = JsonConvert.DeserializeObject <Settings>(content); var dir = Path.GetDirectoryName(configFilePath); Settings.API.Path = Path.Combine(dir, Settings.API.Path); Settings.CSI.Path = Path.Combine(dir, Settings.CSI.Path); Settings.CRI.Path = Path.Combine(dir, Settings.CRI.Path); Settings.Repository.Path = isDevelopment ? Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) : Path.Combine(dir, Settings.Repository.Path); if (!Directory.Exists(Settings.API.Path)) { Directory.CreateDirectory(Settings.API.Path); } if (!Directory.Exists(Settings.CSI.Path)) { Directory.CreateDirectory(Settings.CSI.Path); } if (!Directory.Exists(Settings.CRI.Path)) { Directory.CreateDirectory(Settings.CRI.Path); } if (!Directory.Exists(Settings.Repository.Path)) { Directory.CreateDirectory(Settings.Repository.Path); } ServiceResourceManager.Load(); OnLoaded?.Invoke(null, null); }