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 Process currentVpnProcess;
|
||||||
private static bool shouldBeRunning;
|
private static bool shouldBeRunning;
|
||||||
private static bool isRestarting;
|
private static bool isRestarting;
|
||||||
private const int startingTime = 3000;
|
private const int dstartingTime = 3000;
|
||||||
private const int restartDelay = 250;
|
private const int drestartDelay = 250;
|
||||||
private static DaemonConfig config;
|
private static DaemonConfig config;
|
||||||
public const string daemonConfigPath = "/etc/melon-vpn/daemon.cfg";
|
public const string daemonConfigPath = "/etc/melon-vpn/daemon.cfg";
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ namespace MelonVPNCore
|
|||||||
Console.WriteLine("Restarting embedded process");
|
Console.WriteLine("Restarting embedded process");
|
||||||
currentVpnProcess.Dispose();
|
currentVpnProcess.Dispose();
|
||||||
currentVpnProcess = null;
|
currentVpnProcess = null;
|
||||||
Thread.Sleep(restartDelay);
|
Thread.Sleep((config.restartDelay < drestartDelay) ? drestartDelay : config.restartDelay);
|
||||||
bool imonline = false;
|
bool imonline = false;
|
||||||
isRestarting = true;
|
isRestarting = true;
|
||||||
while (config.ShouldRestart && shouldBeRunning)
|
while (config.ShouldRestart && shouldBeRunning)
|
||||||
@ -213,7 +213,7 @@ namespace MelonVPNCore
|
|||||||
{
|
{
|
||||||
currentVpnProcess.Dispose();
|
currentVpnProcess.Dispose();
|
||||||
currentVpnProcess = null;
|
currentVpnProcess = null;
|
||||||
Thread.Sleep(restartDelay);
|
Thread.Sleep((config.restartDelay < drestartDelay) ? drestartDelay : config.restartDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isRestarting = false;
|
isRestarting = false;
|
||||||
@ -239,7 +239,7 @@ namespace MelonVPNCore
|
|||||||
};
|
};
|
||||||
currentVpnProcess.Exited += CurrentVpnProcess_Exited;
|
currentVpnProcess.Exited += CurrentVpnProcess_Exited;
|
||||||
currentVpnProcess.Start();
|
currentVpnProcess.Start();
|
||||||
Thread.Sleep(startingTime);
|
Thread.Sleep((config.StartingTime < dstartingTime) ? dstartingTime : config.StartingTime);
|
||||||
return !currentVpnProcess.HasExited;
|
return !currentVpnProcess.HasExited;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -76,5 +76,11 @@ namespace MelonVPNCore
|
|||||||
|
|
||||||
[JsonProperty("restart")]
|
[JsonProperty("restart")]
|
||||||
public bool ShouldRestart { get; set; }
|
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