Skip to content

Commit

Permalink
Fix linux compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
WorkingRobot committed Jan 24, 2025
1 parent 2beba93 commit ef00d96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 1 addition & 3 deletions web/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@
"rust-analyzer.server.extraEnv": {
"DATABASE_URL": "postgresql://waitingway:waitingway_passwd@localhost:5432/waitingway"
},
"rust-analyzer.check.extraEnv": {
"DATABASE_URL": "postgresql://waitingway:waitingway_passwd@localhost:5432/waitingway"
}
// "rust-analyzer.cargo.target": "x86_64-unknown-linux-gnu"
}
15 changes: 9 additions & 6 deletions web/src/natives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ pub fn process_start_time() -> Result<OffsetDateTime> {
pub fn process_start_time() -> Result<OffsetDateTime> {
use procfs::{boot_time_secs, process::Process, ticks_per_second};

Process::myself().and_then(|p| p.stat()).and_then(|stat| {
let seconds_since_boot = stat.starttime as f64 / ticks_per_second() as f64;
Ok(Process::myself()
.and_then(|p| p.stat())
.and_then(|stat| {
let seconds_since_boot = stat.starttime as f64 / ticks_per_second() as f64;

Ok(OffsetDateTime::UNIX_EPOCH
+ Duration::seconds(boot_time_secs()? as i64)
+ Duration::seconds_f64(seconds_since_boot))
})
Ok(OffsetDateTime::UNIX_EPOCH
+ Duration::seconds(boot_time_secs()? as i64)
+ Duration::seconds_f64(seconds_since_boot))
})
.map_err(anyhow::Error::from)?)
}

pub fn process_uptime() -> Result<Duration> {
Expand Down

0 comments on commit ef00d96

Please sign in to comment.