mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 21:13:09 +00:00
Refactor/service manager (#2401)
* wip: Pulling in the features of the refactor since march * chore: Fixes to make the system able to build * chore: Adding in the documentation for the manager stuff * feat: Restarting and wait for stop * feat: Add a soft shutdown not commit to db. * chore: Remove the comments of bluj * chore: Clean up some of the linting errors * chore: Clean up the signal * chore: Some more cleanup * fix: The configure * fix: A missing config * fix: typo * chore: Remove a comment of BLUJ that needed to be removed
This commit is contained in:
@@ -522,7 +522,6 @@ pub fn dir_copy<'a, P0: AsRef<Path> + 'a + Send + Sync, P1: AsRef<Path> + 'a + S
|
||||
let src_path = e.path();
|
||||
let dst_path = dst_path.join(e.file_name());
|
||||
if m.is_file() {
|
||||
let len = m.len();
|
||||
let mut dst_file = tokio::fs::File::create(&dst_path).await.with_ctx(|_| {
|
||||
(
|
||||
crate::ErrorKind::Filesystem,
|
||||
@@ -638,7 +637,7 @@ impl<S: AsyncRead + AsyncWrite> AsyncWrite for TimeoutStream<S> {
|
||||
cx: &mut std::task::Context<'_>,
|
||||
buf: &[u8],
|
||||
) -> std::task::Poll<Result<usize, std::io::Error>> {
|
||||
let mut this = self.project();
|
||||
let this = self.project();
|
||||
let res = this.stream.poll_write(cx, buf);
|
||||
if res.is_ready() {
|
||||
this.sleep.reset(Instant::now() + *this.timeout);
|
||||
@@ -649,7 +648,7 @@ impl<S: AsyncRead + AsyncWrite> AsyncWrite for TimeoutStream<S> {
|
||||
self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<Result<(), std::io::Error>> {
|
||||
let mut this = self.project();
|
||||
let this = self.project();
|
||||
let res = this.stream.poll_flush(cx);
|
||||
if res.is_ready() {
|
||||
this.sleep.reset(Instant::now() + *this.timeout);
|
||||
@@ -660,7 +659,7 @@ impl<S: AsyncRead + AsyncWrite> AsyncWrite for TimeoutStream<S> {
|
||||
self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<Result<(), std::io::Error>> {
|
||||
let mut this = self.project();
|
||||
let this = self.project();
|
||||
let res = this.stream.poll_shutdown(cx);
|
||||
if res.is_ready() {
|
||||
this.sleep.reset(Instant::now() + *this.timeout);
|
||||
|
||||
@@ -170,9 +170,7 @@ impl<W: std::fmt::Write> std::io::Write for FmtWriter<W> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn display_none<T>(_: T, _: &ArgMatches) {
|
||||
()
|
||||
}
|
||||
pub fn display_none<T>(_: T, _: &ArgMatches) {}
|
||||
|
||||
pub struct Container<T>(RwLock<Option<T>>);
|
||||
impl<T> Container<T> {
|
||||
@@ -256,6 +254,29 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GeneralBoxedGuard(Option<Box<dyn FnOnce() + Send + Sync>>);
|
||||
impl GeneralBoxedGuard {
|
||||
pub fn new(f: impl FnOnce() + 'static + Send + Sync) -> Self {
|
||||
GeneralBoxedGuard(Some(Box::new(f)))
|
||||
}
|
||||
|
||||
pub fn drop(mut self) {
|
||||
self.0.take().unwrap()()
|
||||
}
|
||||
|
||||
pub fn drop_without_action(mut self) {
|
||||
self.0 = None;
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for GeneralBoxedGuard {
|
||||
fn drop(&mut self) {
|
||||
if let Some(destroy) = self.0.take() {
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GeneralGuard<F: FnOnce() -> T, T = ()>(Option<F>);
|
||||
impl<F: FnOnce() -> T, T> GeneralGuard<F, T> {
|
||||
pub fn new(f: F) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user