This commit is contained in:
BlubbFish 2018-06-02 17:14:42 +00:00
parent a76234f43d
commit 25e1e5165d
17 changed files with 14 additions and 24 deletions

View File

@ -6,7 +6,7 @@ using BlubbFish.Utils;
namespace ZwayBot { namespace ZwayBot {
abstract class AModul { abstract class AModul {
protected ZwayController zw; protected ZwayController zw;
private InIReader settings; private readonly InIReader settings;
protected Dictionary<String, Dictionary<String, String>> config = new Dictionary<String, Dictionary<String, String>>(); protected Dictionary<String, Dictionary<String, String>> config = new Dictionary<String, Dictionary<String, String>>();
public Boolean HasConfig { get; private set; } public Boolean HasConfig { get; private set; }

View File

@ -16,7 +16,7 @@ namespace ZwayBot.Moduls {
public override event ModulEvent Update; public override event ModulEvent Update;
private Dictionary<String, String> cron_named = new Dictionary<String, String> { private readonly Dictionary<String, String> cron_named = new Dictionary<String, String> {
{ "@yearly", "0 0 1 1 *" }, { "@yearly", "0 0 1 1 *" },
{ "@annually", "0 0 1 1 *" }, { "@annually", "0 0 1 1 *" },
{ "@monthly", "0 0 1 * *" }, { "@monthly", "0 0 1 * *" },
@ -166,19 +166,13 @@ namespace ZwayBot.Moduls {
if (!this.disposedValue) { if (!this.disposedValue) {
if (disposing) { if (disposing) {
this.thread.Abort(); this.thread.Abort();
while(this.thread.ThreadState != ThreadState.Aborted) { Thread.Sleep(100); } while(this.thread.ThreadState == ThreadState.Running) { Thread.Sleep(100); }
} }
this.thread = null; this.thread = null;
this.disposedValue = true; this.disposedValue = true;
} }
} }
~CronJob() {
Dispose(false);
}
public override void Dispose() { public override void Dispose() {
Dispose(true); Dispose(true);
GC.SuppressFinalize(this); GC.SuppressFinalize(this);

View File

@ -11,7 +11,7 @@ using LitJson;
namespace ZwayBot.Moduls { namespace ZwayBot.Moduls {
class Mqtt : AModul, IDisposable { class Mqtt : AModul, IDisposable {
private ABackend mqtt; private readonly ABackend mqtt;
private Dictionary<String, AModul> modules; private Dictionary<String, AModul> modules;
public override event ModulEvent Update; public override event ModulEvent Update;

View File

@ -7,7 +7,7 @@ using BlubbFish.Utils;
namespace ZwayBot.Moduls { namespace ZwayBot.Moduls {
internal class Overtaker : AModul, IDisposable { internal class Overtaker : AModul, IDisposable {
private Dictionary<String, Dictionary<String, String>> events = new Dictionary<String, Dictionary<String, String>>(); private readonly Dictionary<String, Dictionary<String, String>> events = new Dictionary<String, Dictionary<String, String>>();
public override event ModulEvent Update; public override event ModulEvent Update;
@ -89,10 +89,6 @@ namespace ZwayBot.Moduls {
} }
} }
~Overtaker() {
Dispose(false);
}
public override void Dispose() { public override void Dispose() {
Dispose(true); Dispose(true);
GC.SuppressFinalize(this); GC.SuppressFinalize(this);

View File

@ -9,8 +9,8 @@ using BlubbFish.Utils.IoT.Interfaces;
namespace ZwayBot.Moduls { namespace ZwayBot.Moduls {
class Senml : AModul { class Senml : AModul {
public override event ModulEvent Update; public override event ModulEvent Update;
private ABackend mqtt; private readonly ABackend mqtt;
private String SenmlGuid; private readonly String SenmlGuid;
public Senml(ZwayController zway, InIReader settings) : base(zway, settings) { public Senml(ZwayController zway, InIReader settings) : base(zway, settings) {
if (this.config.ContainsKey("settings")) { if (this.config.ContainsKey("settings")) {

View File

@ -51,10 +51,11 @@ namespace ZwayBot {
new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGINT) new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGINT)
}; };
Console.WriteLine("Signalhandler Mono attached."); Console.WriteLine("Signalhandler Mono attached.");
while (this.RunningProcess) { while (true) {
Int32 i = Mono.Unix.UnixSignal.WaitAny(signals, -1); Int32 i = Mono.Unix.UnixSignal.WaitAny(signals, -1);
Console.WriteLine("Signalhandler Mono INT recieved " + i + "."); Console.WriteLine("Signalhandler Mono INT recieved " + i + ".");
this.RunningProcess = false; this.RunningProcess = false; // TODO BUG
break;
} }
}); });
this.sig_thread.Start(); this.sig_thread.Start();

View File

@ -31,8 +31,8 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.1")] [assembly: AssemblyVersion("1.5.2")]
[assembly: AssemblyFileVersion("1.5.1")] [assembly: AssemblyFileVersion("1.5.2")]
[assembly: NeutralResourcesLanguage("de-DE")] [assembly: NeutralResourcesLanguage("de-DE")]
// “Internet Of Things” icon by By Michael Wohlwend, US, from thenounproject.com. // “Internet Of Things” icon by By Michael Wohlwend, US, from thenounproject.com.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,3 @@
#!/bin/sh #!/bin/sh
systemctl daemon-reload systemctl daemon-reload
service zwaybot start

View File

@ -8,7 +8,7 @@ After=network-online.target
User=zwaybot User=zwaybot
Group=zwaybot Group=zwaybot
WorkingDirectory=/usr/local/bin/zwaybot WorkingDirectory=/usr/local/bin/zwaybot
ExecStartPre=/bin/rm /var/log/zwaybot.log && /bin/touch /var/log/zwaybot.log && /bin/chown zwaybot:zwaybot /var/log/zwaybot.log && /bin/chmod 644 /var/log/zwaybot.log # ExecStartPre=/bin/rm /var/log/zwaybot.log && /bin/touch /var/log/zwaybot.log && /bin/chown zwaybot:zwaybot /var/log/zwaybot.log && /bin/chmod 644 /var/log/zwaybot.log
ExecStart=/usr/bin/mono /usr/local/bin/zwaybot/Zway-Bot.exe ExecStart=/usr/bin/mono /usr/local/bin/zwaybot/Zway-Bot.exe
KillMode=control-group KillMode=control-group
Restart=on-failure Restart=on-failure