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:
parent
6cccfbdde3
commit
a003428951
1 changed files with 5 additions and 3 deletions
8
main.go
8
main.go
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue