diff --git a/backend/embassy-init.service b/backend/embassy-init.service index 104f16908..3322f4bf9 100644 --- a/backend/embassy-init.service +++ b/backend/embassy-init.service @@ -9,6 +9,8 @@ Type=oneshot Environment=RUST_LOG=embassy_init=debug,embassy=debug,js_engine=debug ExecStart=/usr/local/bin/embassy-init RemainAfterExit=true +StandardOutput=file:/var/log/embassy-init.out.log +StandardError=file:/var/log/embassy-init.error.log [Install] WantedBy=embassyd.service diff --git a/backend/src/init.rs b/backend/src/init.rs index eecb81d62..8d6e77f79 100644 --- a/backend/src/init.rs +++ b/backend/src/init.rs @@ -160,6 +160,8 @@ pub async fn init(cfg: &RpcContextConfig, product_key: &str) -> Result<(), Error } if warn_time_not_synced { tracing::warn!("Timed out waiting for system time to synchronize"); + } else { + tracing::info!("Syncronized system clock"); } crate::version::init(&mut handle, &receipts).await?; @@ -168,5 +170,7 @@ pub async fn init(cfg: &RpcContextConfig, product_key: &str) -> Result<(), Error tokio::fs::remove_file(SYSTEM_REBUILD_PATH).await?; } + tracing::info!("System initialized."); + Ok(()) } diff --git a/backend/src/version/mod.rs b/backend/src/version/mod.rs index 4a47a5928..3020d9c9b 100644 --- a/backend/src/version/mod.rs +++ b/backend/src/version/mod.rs @@ -97,10 +97,18 @@ where receipts: &InitReceipts, ) -> Result<(), Error> { let previous = Self::Previous::new(); - if version.semver() != previous.semver() { + if version.semver() < previous.semver() { previous .migrate_from_unchecked(version, db, receipts) .await?; + } else if version.semver() > previous.semver() { + return Err(Error::new( + eyre!( + "NO PATH FROM {}, THIS IS LIKELY A MISTAKE IN THE VERSION DEFINITION", + version.semver() + ), + crate::ErrorKind::MigrationFailed, + )); } tracing::info!("{} -> {}", previous.semver(), self.semver(),); self.up(db).await?; @@ -117,10 +125,18 @@ where tracing::info!("{} -> {}", self.semver(), previous.semver(),); self.down(db).await?; previous.commit(db, receipts).await?; - if version.semver() != previous.semver() { + if version.semver() < previous.semver() { previous .rollback_to_unchecked(version, db, receipts) .await?; + } else if version.semver() > previous.semver() { + return Err(Error::new( + eyre!( + "NO PATH TO {}, THIS IS LIKELY A MISTAKE IN THE VERSION DEFINITION", + version.semver() + ), + crate::ErrorKind::MigrationFailed, + )); } Ok(()) } diff --git a/backend/src/version/v0_3_1_1.rs b/backend/src/version/v0_3_1_1.rs index 01b2707b6..055a3bd45 100644 --- a/backend/src/version/v0_3_1_1.rs +++ b/backend/src/version/v0_3_1_1.rs @@ -8,7 +8,7 @@ const V0_3_1_1: emver::Version = emver::Version::new(0, 3, 1, 1); pub struct Version; #[async_trait] impl VersionT for Version { - type Previous = v0_3_0_3::Version; + type Previous = v0_3_1::Version; fn new() -> Self { Version }