mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
fix migration, add logging (#1674)
* fix migration, add logging * change stack overflow to runtime error
This commit is contained in:
@@ -9,6 +9,8 @@ Type=oneshot
|
|||||||
Environment=RUST_LOG=embassy_init=debug,embassy=debug,js_engine=debug
|
Environment=RUST_LOG=embassy_init=debug,embassy=debug,js_engine=debug
|
||||||
ExecStart=/usr/local/bin/embassy-init
|
ExecStart=/usr/local/bin/embassy-init
|
||||||
RemainAfterExit=true
|
RemainAfterExit=true
|
||||||
|
StandardOutput=file:/var/log/embassy-init.out.log
|
||||||
|
StandardError=file:/var/log/embassy-init.error.log
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=embassyd.service
|
WantedBy=embassyd.service
|
||||||
|
|||||||
@@ -160,6 +160,8 @@ pub async fn init(cfg: &RpcContextConfig, product_key: &str) -> Result<(), Error
|
|||||||
}
|
}
|
||||||
if warn_time_not_synced {
|
if warn_time_not_synced {
|
||||||
tracing::warn!("Timed out waiting for system time to synchronize");
|
tracing::warn!("Timed out waiting for system time to synchronize");
|
||||||
|
} else {
|
||||||
|
tracing::info!("Syncronized system clock");
|
||||||
}
|
}
|
||||||
|
|
||||||
crate::version::init(&mut handle, &receipts).await?;
|
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?;
|
tokio::fs::remove_file(SYSTEM_REBUILD_PATH).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tracing::info!("System initialized.");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,10 +97,18 @@ where
|
|||||||
receipts: &InitReceipts,
|
receipts: &InitReceipts,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let previous = Self::Previous::new();
|
let previous = Self::Previous::new();
|
||||||
if version.semver() != previous.semver() {
|
if version.semver() < previous.semver() {
|
||||||
previous
|
previous
|
||||||
.migrate_from_unchecked(version, db, receipts)
|
.migrate_from_unchecked(version, db, receipts)
|
||||||
.await?;
|
.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(),);
|
tracing::info!("{} -> {}", previous.semver(), self.semver(),);
|
||||||
self.up(db).await?;
|
self.up(db).await?;
|
||||||
@@ -117,10 +125,18 @@ where
|
|||||||
tracing::info!("{} -> {}", self.semver(), previous.semver(),);
|
tracing::info!("{} -> {}", self.semver(), previous.semver(),);
|
||||||
self.down(db).await?;
|
self.down(db).await?;
|
||||||
previous.commit(db, receipts).await?;
|
previous.commit(db, receipts).await?;
|
||||||
if version.semver() != previous.semver() {
|
if version.semver() < previous.semver() {
|
||||||
previous
|
previous
|
||||||
.rollback_to_unchecked(version, db, receipts)
|
.rollback_to_unchecked(version, db, receipts)
|
||||||
.await?;
|
.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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const V0_3_1_1: emver::Version = emver::Version::new(0, 3, 1, 1);
|
|||||||
pub struct Version;
|
pub struct Version;
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl VersionT for Version {
|
impl VersionT for Version {
|
||||||
type Previous = v0_3_0_3::Version;
|
type Previous = v0_3_1::Version;
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Version
|
Version
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user