Add more json settings fields for daemon.
This commit is contained in:
parent
b488b29d45
commit
20c88c027c
@ -13,8 +13,8 @@ namespace MelonVPNCore
|
||||
private static Process currentVpnProcess;
|
||||
private static bool shouldBeRunning;
|
||||
private static bool isRestarting;
|
||||
private const int startingTime = 3000;
|
||||
private const int restartDelay = 250;
|
||||
private const int dstartingTime = 3000;
|
||||
private const int drestartDelay = 250;
|
||||
private static DaemonConfig config;
|
||||
public const string daemonConfigPath = "/etc/melon-vpn/daemon.cfg";
|
||||
|
||||
@ -194,7 +194,7 @@ namespace MelonVPNCore
|
||||
Console.WriteLine("Restarting embedded process");
|
||||
currentVpnProcess.Dispose();
|
||||
currentVpnProcess = null;
|
||||
Thread.Sleep(restartDelay);
|
||||
Thread.Sleep((config.restartDelay < drestartDelay) ? drestartDelay : config.restartDelay);
|
||||
bool imonline = false;
|
||||
isRestarting = true;
|
||||
while (config.ShouldRestart && shouldBeRunning)
|
||||
@ -213,7 +213,7 @@ namespace MelonVPNCore
|
||||
{
|
||||
currentVpnProcess.Dispose();
|
||||
currentVpnProcess = null;
|
||||
Thread.Sleep(restartDelay);
|
||||
Thread.Sleep((config.restartDelay < drestartDelay) ? drestartDelay : config.restartDelay);
|
||||
}
|
||||
}
|
||||
isRestarting = false;
|
||||
@ -239,7 +239,7 @@ namespace MelonVPNCore
|
||||
};
|
||||
currentVpnProcess.Exited += CurrentVpnProcess_Exited;
|
||||
currentVpnProcess.Start();
|
||||
Thread.Sleep(startingTime);
|
||||
Thread.Sleep((config.StartingTime < dstartingTime) ? dstartingTime : config.StartingTime);
|
||||
return !currentVpnProcess.HasExited;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -76,5 +76,11 @@ namespace MelonVPNCore
|
||||
|
||||
[JsonProperty("restart")]
|
||||
public bool ShouldRestart { get; set; }
|
||||
|
||||
[JsonProperty("starting_time")]
|
||||
public int StartingTime { get; set; }
|
||||
|
||||
[JsonProperty("restart_delay")]
|
||||
public int restartDelay { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user