Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sd-notify #489

Merged
merged 1 commit into from
Aug 24, 2024
Merged
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
4 changes: 2 additions & 2 deletions aw-server.service
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
#

[Service]
Type=simple
Type=notify
ExecStart=aw-server

[Unit]
Description=ActivityWatch Server (Rust implementation)
Wants=network.target
After=network.target

[Install]
WantedBy=default.target
3 changes: 3 additions & 0 deletions aw-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ aw-models = { path = "../aw-models" }
aw-transform = { path = "../aw-transform" }
aw-query = { path = "../aw-query" }

[target.'cfg(target_os="linux")'.dependencies]
sd-notify = "0.4.2"

[target.'cfg(all(target_os="linux", target_arch="x86"))'.dependencies]
jemallocator = "0.5.0"

Expand Down
9 changes: 7 additions & 2 deletions aw-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use clap::Parser;

use aw_server::*;

#[cfg(target_os = "linux")]
use sd_notify::NotifyState;
#[cfg(all(target_os = "linux", target_arch = "x86"))]
extern crate jemallocator;
#[cfg(all(target_os = "linux", target_arch = "x86"))]
Expand Down Expand Up @@ -147,9 +149,12 @@ async fn main() -> Result<(), rocket::Error> {
device_id,
};

let _ = endpoints::build_rocket(server_state, config)
.launch()
let _rocket = endpoints::build_rocket(server_state, config)
.ignite()
.await?;
#[cfg(target_os = "linux")]
let _ = sd_notify::notify(true, &[NotifyState::Ready]);
wojnilowicz marked this conversation as resolved.
Show resolved Hide resolved
_rocket.launch().await?;

Ok(())
}
Loading