Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ rkyv = { version = "0.8.10", features = ["little_endian"] }
form-data = { version = "0.6.0", features = ["sync"], default-features = false }
mime = "0.3.17"
compact_str = "0.9.0"
sd-notify = "0.4.5"

[dev-dependencies]

Expand Down
14 changes: 10 additions & 4 deletions crates/http/src/management/reload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use common::{
ipc::{BroadcastEvent, HousekeeperEvent},
};
use directory::Permission;
use http_proto::*;
use hyper::Method;
use sd_notify;
use serde_json::json;
use std::future::Future;
use utils::url_params::UrlParams;

use http_proto::*;

pub trait ManageReload: Sync + Send {
fn handle_manage_reload(
&self,
Expand All @@ -43,7 +43,9 @@ impl ManageReload for Server {
// Validate the access token
access_token.assert_has_permission(Permission::SettingsReload)?;

match (path.get(1).copied(), req.method()) {
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Reloading]);

let response = match (path.get(1).copied(), req.method()) {
(Some("lookup"), &Method::GET) => {
let result = self.reload_lookups().await?;
// Update core
Expand Down Expand Up @@ -117,7 +119,11 @@ impl ManageReload for Server {
.into_http_response())
}
_ => Err(trc::ResourceEvent::NotFound.into_err()),
}
};

let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Ready]);

response
}

async fn handle_manage_update(
Expand Down
1 change: 1 addition & 0 deletions crates/main/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ trc = { path = "../trc" }
utils = { path = "../utils" }
migration = { path = "../migration" }
tokio = { version = "1.47", features = ["full"] }
sd-notify = "0.4.5"

[target.'cfg(not(target_env = "msvc"))'.dependencies]
jemallocator = "0.5.0"
Expand Down
5 changes: 5 additions & 0 deletions crates/main/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use http::HttpSessionManager;
use imap::core::ImapSessionManager;
use managesieve::core::ManageSieveSessionManager;
use pop3::Pop3SessionManager;
use sd_notify;
use services::{StartServices, broadcast::subscriber::spawn_broadcast_subscriber};
use smtp::{StartQueueManager, core::SmtpSessionManager};
use std::time::Duration;
Expand Down Expand Up @@ -97,9 +98,13 @@ async fn main() -> std::io::Result<()> {
// Start broadcast subscriber
spawn_broadcast_subscriber(init.inner, shutdown_rx);

let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Ready]);

// Wait for shutdown signal
wait_for_shutdown().await;

let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Stopping]);

// Shutdown collector
Collector::shutdown();

Expand Down