Commit Diff


commit - c6b1d112887e139711143d2f6948b788f7502a37
commit + eb075e3595bdbd8711b07cef09392bdc4c036611
blob - 9bad03daa9c5ffc138b9b6010f770679b586abf6
blob + bb0982e892ec7675271a740e854003530de200c5
--- src/metrics.rs
+++ src/metrics.rs
@@ -2,6 +2,7 @@ use std::{
     borrow::Cow,
     io::{self, Write},
     iter::FusedIterator,
+    time::UNIX_EPOCH,
 };
 
 use crate::s6::{ServiceDir, Status, SupervisedStatus};
@@ -107,8 +108,16 @@ impl<'w, W: Write, I: Iterator<Item = ServiceDir>> Wri
             if status.ready { 1 } else { 0 },
             if status.paused { 1 } else { 0 },
             status.pid,
-            status.up_down_since.as_secs(),
-            status.ready_since.as_secs(),
+            status
+                .up_down_since
+                .duration_since(UNIX_EPOCH)
+                .expect("positive timestamp")
+                .as_secs(),
+            status
+                .ready_since
+                .duration_since(UNIX_EPOCH)
+                .expect("positive timestamp")
+                .as_secs(),
         )?;
         if let Some(exit_code) = status.exit_code {
             writeln!(
blob - 95e8a09b35b088df992cb69353a86cdbda243fc5
blob + 7892d83722fe9deac3ba14bac87cfe4cc7c5fbb6
--- src/s6/status.rs
+++ src/s6/status.rs
@@ -3,14 +3,14 @@ use std::{
     io::{self, Read},
     os::unix::process::ExitStatusExt,
     process::ExitStatus,
-    time::Duration,
+    time::SystemTime,
 };
 
 use super::tai::Tain;
 
 pub(super) struct SvStatus {
-    pub stamp: Duration,
-    pub ready_stamp: Duration,
+    pub stamp: SystemTime,
+    pub ready_stamp: SystemTime,
     pub pid: u64,
     pub wait_status: ExitStatus,
     pub paused: bool,
blob - becc759a36616afb1054bb276b82aa6b12787674
blob + cbfea709524cbe80bc6cc7b287dd95df3eedb4f9
--- src/s6/tai.rs
+++ src/s6/tai.rs
@@ -1,4 +1,4 @@
-use std::time::Duration;
+use std::time::{Duration, SystemTime};
 
 struct Tai(u64);
 
@@ -24,8 +24,8 @@ impl Tain {
     }
 }
 
-impl From<Tain> for Duration {
+impl From<Tain> for SystemTime {
     fn from(tain: Tain) -> Self {
-        Self::new(tain.sec.0 - Tai::EPOCH, tain.nano)
+        SystemTime::UNIX_EPOCH + Duration::new(tain.sec.0 - Tai::EPOCH, tain.nano)
     }
 }
blob - 37137fc0b6e9254269ed80581913e61985e16f47
blob + 917ccd0cfd4b8ccfe574adc026627cac875d2cbf
--- src/s6.rs
+++ src/s6.rs
@@ -8,7 +8,7 @@ use std::{
     },
     path::{Path, PathBuf},
     ptr::addr_of_mut,
-    time::Duration,
+    time::SystemTime,
 };
 
 mod status;
@@ -41,8 +41,8 @@ pub struct SupervisedStatus {
     pub exit_code: Option<i32>,
     // signal
     pub signal_number: Option<i32>,
-    pub up_down_since: Duration,
-    pub ready_since: Duration,
+    pub up_down_since: SystemTime,
+    pub ready_since: SystemTime,
 }
 
 pub enum Status {