Compare commits

...
1 Commits
Author SHA1 Message Date
BlubbFish 002b3cf338 [NF] Logrotate 2018-05-29 20:07:50 +00:00
14 changed files with 33 additions and 9 deletions
+8 -3
View File
@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Threading;
using BlubbFish.IoT.Zway; using BlubbFish.IoT.Zway;
using BlubbFish.Utils; using BlubbFish.Utils;
@@ -11,7 +12,7 @@ namespace ZwayBot {
private readonly ZwayController zw; private readonly ZwayController zw;
private readonly Dictionary<String, AModul> moduls = new Dictionary<String, AModul>(); private readonly Dictionary<String, AModul> moduls = new Dictionary<String, AModul>();
private Boolean RunningProcess = true; private Boolean RunningProcess = true;
private System.Threading.Thread sig_thread; private Thread sig_thread;
private readonly ProgramLogger logger = new ProgramLogger(); private readonly ProgramLogger logger = new ProgramLogger();
public Program(String[] args) { public Program(String[] args) {
@@ -44,27 +45,31 @@ namespace ZwayBot {
private void WaitForShutdown() { private void WaitForShutdown() {
if (Type.GetType("Mono.Runtime") != null) { if (Type.GetType("Mono.Runtime") != null) {
this.sig_thread = new System.Threading.Thread(delegate () { this.sig_thread = new Thread(delegate () {
Mono.Unix.UnixSignal[] signals = new Mono.Unix.UnixSignal[] { Mono.Unix.UnixSignal[] signals = new Mono.Unix.UnixSignal[] {
new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGTERM), new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGTERM),
new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGINT) new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGINT)
}; };
Console.WriteLine("Signalhandler Mono attached.");
while (this.RunningProcess) { while (this.RunningProcess) {
Int32 i = Mono.Unix.UnixSignal.WaitAny(signals, -1); Int32 i = Mono.Unix.UnixSignal.WaitAny(signals, -1);
Console.WriteLine("Signalhandler Mono INT recieved " + i + ".");
this.RunningProcess = false; this.RunningProcess = false;
} }
}); });
this.sig_thread.Start(); this.sig_thread.Start();
} else { } else {
Console.CancelKeyPress += new ConsoleCancelEventHandler(this.SetupShutdown); Console.CancelKeyPress += new ConsoleCancelEventHandler(this.SetupShutdown);
Console.WriteLine("Signalhandler Windows attached.");
} }
while (this.RunningProcess) { while (this.RunningProcess) {
System.Threading.Thread.Sleep(100); Thread.Sleep(100);
} }
} }
private void SetupShutdown(Object sender, ConsoleCancelEventArgs e) { private void SetupShutdown(Object sender, ConsoleCancelEventArgs e) {
e.Cancel = true; e.Cancel = true;
Console.WriteLine("Signalhandler Windows INT recieved.");
this.RunningProcess = false; this.RunningProcess = false;
} }
+2 -2
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.0")] [assembly: AssemblyVersion("1.5.1")]
[assembly: AssemblyFileVersion("1.5.0")] [assembly: AssemblyFileVersion("1.5.1")]
[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.
+1
View File
@@ -125,6 +125,7 @@
<None Include="dpkg\create-Builds.bat" /> <None Include="dpkg\create-Builds.bat" />
<None Include="dpkg\make-deb.sh" /> <None Include="dpkg\make-deb.sh" />
<None Include="dpkg\prerm" /> <None Include="dpkg\prerm" />
<None Include="dpkg\zwaybot-logrotate" />
<None Include="dpkg\zwaybot.service" /> <None Include="dpkg\zwaybot.service" />
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Resources\Icon.ico" /> <None Include="Resources\Icon.ico" />
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+7
View File
@@ -3,9 +3,12 @@
HOMEDIR="/home/blubb" HOMEDIR="/home/blubb"
ROOT="$HOMEDIR/deb" ROOT="$HOMEDIR/deb"
OUTPUT="../bin/Release" OUTPUT="../bin/Release"
EXEC="$ROOT/usr/local/bin/zwaybot" EXEC="$ROOT/usr/local/bin/zwaybot"
CONFIG="$ROOT/etc/zwaybot" CONFIG="$ROOT/etc/zwaybot"
SYSTEMD="$ROOT/etc/systemd/system" SYSTEMD="$ROOT/etc/systemd/system"
LOGROTATE="$ROOT/etc/logrotate.d"
DEBIAN="$ROOT/DEBIAN" DEBIAN="$ROOT/DEBIAN"
VMAJOR=$(grep -e "^\[assembly: AssemblyVersion(\"" ../Properties/AssemblyInfo.cs | cut -d'"' -f 2 | cut -d'.' -f 1) VMAJOR=$(grep -e "^\[assembly: AssemblyVersion(\"" ../Properties/AssemblyInfo.cs | cut -d'"' -f 2 | cut -d'.' -f 1)
VMINOR=$(grep -e "^\[assembly: AssemblyVersion(\"" ../Properties/AssemblyInfo.cs | cut -d'"' -f 2 | cut -d'.' -f 2) VMINOR=$(grep -e "^\[assembly: AssemblyVersion(\"" ../Properties/AssemblyInfo.cs | cut -d'"' -f 2 | cut -d'.' -f 2)
@@ -16,6 +19,7 @@ mkdir -p $EXEC
mkdir -p $CONFIG mkdir -p $CONFIG
mkdir -p $DEBIAN mkdir -p $DEBIAN
mkdir -p $SYSTEMD mkdir -p $SYSTEMD
mkdir -p $LOGROTATE
cp control $DEBIAN cp control $DEBIAN
cp preinst $DEBIAN cp preinst $DEBIAN
@@ -37,6 +41,9 @@ cp $OUTPUT/config-example/* $CONFIG
chmod 644 $CONFIG/* chmod 644 $CONFIG/*
chmod 755 $CONFIG chmod 755 $CONFIG
cp zwaybot-logrotate $LOGROTATE/zwaybot
chmod 644 $LOGROTATE/*
dpkg-deb --build $ROOT dpkg-deb --build $ROOT
mv $HOMEDIR/deb.deb ../../../Builds/$ARCHT/"zwaybot_$VMAJOR.$VMINOR-$VBUILD.deb" mv $HOMEDIR/deb.deb ../../../Builds/$ARCHT/"zwaybot_$VMAJOR.$VMINOR-$VBUILD.deb"
rm $HOMEDIR/deb -r rm $HOMEDIR/deb -r
+10
View File
@@ -0,0 +1,10 @@
/var/log/zwaybot.log {
compress
copytruncate
daily
delaycompress
missingok
notifempty
rotate 4
size=10M
}
+2 -1
View File
@@ -8,10 +8,11 @@ After=network-online.target
User=zwaybot User=zwaybot
Group=zwaybot Group=zwaybot
WorkingDirectory=/usr/local/bin/zwaybot WorkingDirectory=/usr/local/bin/zwaybot
ExecStartPre=rm /var/log/zwaybot.log && touch /var/log/zwaybot.log && chown zwaybot:zwaybot /var/log/zwaybot.log && 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
StandardOutput=null
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target