environment logic improvement

This commit is contained in:
root 2020-06-07 22:48:43 +02:00
parent 60965753f0
commit 9b4d28ec64
3 changed files with 141 additions and 142 deletions

View File

@ -32,11 +32,8 @@ namespace LetsEncrypt
} }
public void Run() { public void Run() {
_appSettings.environments.Where(env => env.active).ToList().ForEach(env => {
try try {
{
LetsEncrypt.Helpers.Environment env = _appSettings.environments.Where(x => x.name == _appSettings.active).FirstOrDefault();
Console.WriteLine(string.Format("Let's Encrypt C# .Net Core Client, environment: {0}", env.name)); Console.WriteLine(string.Format("Let's Encrypt C# .Net Core Client, environment: {0}", env.name));
//loop all customers //loop all customers
@ -186,13 +183,16 @@ namespace LetsEncrypt
} }
} }
if(env.name == "ProductionV2") {
_terminalService.Exec("systemctl restart nginx"); _terminalService.Exec("systemctl restart nginx");
}
} }
catch (Exception ex) { catch (Exception ex) {
Console.WriteLine(ex.Message.ToString()); Console.WriteLine(ex.Message.ToString());
} }
});
} }
} }
} }

View File

@ -1,12 +1,12 @@
namespace LetsEncrypt.Helpers namespace LetsEncrypt.Helpers
{ {
public class AppSettings { public class AppSettings {
public string active { get; set; }
public Environment [] environments { get; set; } public Environment [] environments { get; set; }
public Customer [] customers { get; set;} public Customer [] customers { get; set;}
} }
public class Environment { public class Environment {
public bool active { get; set; }
public string name { get; set; } public string name { get; set; }
public string url { get; set; } public string url { get; set; }
public string cache { get; set; } public string cache { get; set; }

View File

@ -1,10 +1,8 @@
{ {
"AppSettings": { "AppSettings": {
"active": "StagingV2",
"environments": [ "environments": [
{ {
"active": true,
"name": "StagingV2", "name": "StagingV2",
"url": "https://acme-staging-v02.api.letsencrypt.org/directory", "url": "https://acme-staging-v02.api.letsencrypt.org/directory",
@ -14,6 +12,7 @@
"ssl": "/home/maksym/source/temp" "ssl": "/home/maksym/source/temp"
}, },
{ {
"active": false,
"name": "ProductionV2", "name": "ProductionV2",
"url": "https://acme-v02.api.letsencrypt.org/directory", "url": "https://acme-v02.api.letsencrypt.org/directory",