From 272b2aa375d66b5b349693b175802008cbba1833 Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Fri, 22 Jan 2021 09:14:03 +0100 Subject: [PATCH] Add systemd service information. --- doc/hmci.service | 10 ++++++++++ doc/service.txt | 4 ++++ src/main/java/biz/nellemann/hmci/InfluxClient.java | 8 ++++---- 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 doc/hmci.service create mode 100644 doc/service.txt diff --git a/doc/hmci.service b/doc/hmci.service new file mode 100644 index 0000000..bf34023 --- /dev/null +++ b/doc/hmci.service @@ -0,0 +1,10 @@ +[Unit] +Description=HMC Insights Service + +[Service] +TimeoutStartSec=0 +Restart=always +ExecStart=/opt/hmci/bin/hmci + +[Install] +WantedBy=default.target diff --git a/doc/service.txt b/doc/service.txt new file mode 100644 index 0000000..5833d79 --- /dev/null +++ b/doc/service.txt @@ -0,0 +1,4 @@ +To setup as a systemd service, copy the hmci.service +file into /etc/systemd/system/ and enable the service: + + systemctl enable hmci.service diff --git a/src/main/java/biz/nellemann/hmci/InfluxClient.java b/src/main/java/biz/nellemann/hmci/InfluxClient.java index b1a2d76..dfffc55 100644 --- a/src/main/java/biz/nellemann/hmci/InfluxClient.java +++ b/src/main/java/biz/nellemann/hmci/InfluxClient.java @@ -105,11 +105,11 @@ class InfluxClient { synchronized void writeBatchPoints() throws Exception { log.debug("writeBatchPoints()"); try { - influxDB.write(batchPoints); + influxDB.writeWithRetry(batchPoints); } catch(Exception e) { - log.error("writeBatchPoints() error - " + e.getMessage(), e); - if(++errorCounter > 3) { - log.info("writeBatchPoints() trying to logout / login"); + log.error("writeBatchPoints() error - " + e.getMessage()); + if(++errorCounter > 5) { + log.info("writeBatchPoints() forcing logout / login"); errorCounter = 0; logoff(); login();