From cd4eaca378643e3fae9cc9fcf2119cae6ba97d74 Mon Sep 17 00:00:00 2001 From: pks Date: Mon, 10 May 2021 13:26:26 +0200 Subject: proper daemon --- config/config.yaml | 34 +++++++++++++++----------- config/logrotate/weather-logger-receiver | 12 +++++++++ config/syslog/50weather-logger-receiver.conf | 1 + config/systemd/weather-logger-receiver.service | 22 +++++++++++++++++ 4 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 config/logrotate/weather-logger-receiver create mode 100644 config/syslog/50weather-logger-receiver.conf create mode 100644 config/systemd/weather-logger-receiver.service (limited to 'config') diff --git a/config/config.yaml b/config/config.yaml index 0986e39..332f6b9 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -1,14 +1,20 @@ -Berlin: - "f4:01": - handle: "inside" - type: "THGR810, THGN800" - "1f:01": - handle: "outside" - type: "BTHR918" -Heidenheim: - "07:01": - handle: "inside" - type: "THC238/268,THN132,THWR288,THRN122,THN122,AW129/131" - "58:02": - handle: "outside" - type: "THGR810, THGN800" +log_file_path: /var/log/weather_logger/receiver.log +pid_file_path: /run/weather_logger/receiver.log + +locations: + Berlin: + "f4:01": + handle: "inside" + type: "THGR810, THGN800" + "1f:01": + handle: "outside" + type: "BTHR918" + Heidenheim: + "07:01": + handle: "inside" + type: "THC238/268,THN132,THWR288,THRN122,THN122,AW129/131" + "58:02": + handle: "outside" + type: "THGR810, THGN800" + +active-location: Berlin diff --git a/config/logrotate/weather-logger-receiver b/config/logrotate/weather-logger-receiver new file mode 100644 index 0000000..c83fbd5 --- /dev/null +++ b/config/logrotate/weather-logger-receiver @@ -0,0 +1,12 @@ +/var/log/weather_logger/receiver.log { + rotate 7 + daily + compress + size 100k + nocreate + missingok + postrotate + kill -HUP `cat /run/weather_logger/receiver.pid` + rm -f /run/weather_logger/receiver.pid + endscript +} diff --git a/config/syslog/50weather-logger-receiver.conf b/config/syslog/50weather-logger-receiver.conf new file mode 100644 index 0000000..9ac4088 --- /dev/null +++ b/config/syslog/50weather-logger-receiver.conf @@ -0,0 +1 @@ +:programname, isequal, "weather-logger-receiver" /var/log/weather_logger/receiver.log diff --git a/config/systemd/weather-logger-receiver.service b/config/systemd/weather-logger-receiver.service new file mode 100644 index 0000000..f56c915 --- /dev/null +++ b/config/systemd/weather-logger-receiver.service @@ -0,0 +1,22 @@ +[Unit] +Description=weather-logger-receiver +After=network.target +StartLimitIntervalSec=0 + +[Service] +Type=simple +Restart=always +RestartSec=1 +User=pks +Group=pks +Environment=PYTHONUNBUFFERED=1 +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=weather-logger-receiver +PIDFile=/run/weather_logger/receiver.pid +ExecStart=/usr/local/src/weather_logger/weather-logger-receiver Berlin +ExecStartPre=rm -f /run/weather_logger/receiver.pid +ExecStopPost=rm -f /run/weather_logger/receiver.pid + +[Install] +WantedBy=multi-user.target -- cgit v1.2.3