Deleting beacon file at shutdown

This commit is contained in:
Dennis Schwerdel 2019-12-19 16:09:52 +01:00
parent 0d29293309
commit f7ed961317
2 changed files with 13 additions and 2 deletions

View File

@ -8,6 +8,7 @@ This project follows [semantic versioning](http://semver.org).
- [changed] Also drop privileges in foreground mode - [changed] Also drop privileges in foreground mode
- [changed] Set builders to Ubuntu 16.04 and CentOS 7 - [changed] Set builders to Ubuntu 16.04 and CentOS 7
- [changed] Set keepalive to 120 secs when NAT is detected - [changed] Set keepalive to 120 secs when NAT is detected
- [changed] Deleting beacon file at shutdown
- [fixed] Added parameter keepalive to manpage - [fixed] Added parameter keepalive to manpage
- [fixed] Fixed problems on stats file when dropping permissions - [fixed] Fixed problems on stats file when dropping permissions
- [fixed] Deleting files before overwriting them - [fixed] Deleting files before overwriting them

View File

@ -6,11 +6,12 @@ use std::{
cmp::min, cmp::min,
collections::HashMap, collections::HashMap,
fmt, fmt,
fs::File, fs::{self, File},
hash::BuildHasherDefault, hash::BuildHasherDefault,
io::{self, Write}, io::{self, Write},
marker::PhantomData, marker::PhantomData,
net::{SocketAddr, ToSocketAddrs} net::{SocketAddr, ToSocketAddrs},
path::Path
}; };
use fnv::FnvHasher; use fnv::FnvHasher;
@ -826,6 +827,15 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
} }
info!("Shutting down..."); info!("Shutting down...");
self.broadcast_msg(&mut Message::Close).ok(); self.broadcast_msg(&mut Message::Close).ok();
if let Some(ref path) = self.config.beacon_store {
let path = Path::new(path);
if path.exists() {
info!("Removing beacon file");
if let Err(e) = fs::remove_file(path) {
error!("Failed to remove beacon file: {}", e)
}
}
}
} }
} }