1
0
Fork 0
mirror of https://github.com/Luzifer/continuous-spark.git synced 2024-12-20 01:31:24 +00:00

Prevent crash when influx client is not present

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2020-11-30 20:49:05 +01:00
parent 6cccfbdde3
commit a003428951
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -64,8 +64,10 @@ func main() {
if cfg.OneShot {
// Return before loop for oneshot execution
if err := metrics.ForceTransmit(); err != nil {
log.WithError(err).Error("Unable to store metrics")
if metrics != nil {
if err := metrics.ForceTransmit(); err != nil {
log.WithError(err).Error("Unable to store metrics")
}
}
return
}
@ -148,7 +150,7 @@ func updateStats(t *testResult, err error) error {
func writeTSV(t *testResult) error {
if _, err := os.Stat(cfg.TSVFile); err != nil && os.IsNotExist(err) {
if err := ioutil.WriteFile(cfg.TSVFile, []byte("Date\tPing Min (ms)\tPing Avg (ms)\tPing Max (ms)\tPing StdDev (ms)\tRX Avg (bps)\tTX Avg (bps)\n"), 0644); err != nil {
if err := ioutil.WriteFile(cfg.TSVFile, []byte("Date\tPing Min (ms)\tPing Avg (ms)\tPing Max (ms)\tPing StdDev (ms)\tRX Avg (bps)\tTX Avg (bps)\n"), 0o644); err != nil {
return errors.Wrap(err, "Unable to write initial TSV headers")
}
}