Skip to content

Commit

Permalink
fix(scoop): allow duplicate shim process
Browse files Browse the repository at this point in the history
This commit addresses issues that users have been faced with when
installing komorebi with scoop, which resulted in komorebi exiting
almost immediately without providing any feedback as to what had
happened.

Scoop launches komorebi using an exe shim of the same name, which
results in two komorebi.exe named processes running at the same time.

This situation then fails the startup check which attempts to ensure
that only one instance of komorebi.exe ever runs at any given time.

The process startup check has been updated to allow for two komorebi.exe
named processes to be running if one of them is recognised as a Scoop
shim process.

fix #95
  • Loading branch information
LGUG2Z committed Jan 27, 2022
1 parent 0138a31 commit d182839
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions komorebi/src/main.rs
Expand Up @@ -24,6 +24,7 @@ use lazy_static::lazy_static;
use parking_lot::deadlock;
use parking_lot::Mutex;
use serde::Serialize;
use sysinfo::ProcessExt;
use sysinfo::SystemExt;
use tracing_appender::non_blocking::WorkerGuard;
use tracing_subscriber::layer::SubscriberExt;
Expand Down Expand Up @@ -341,9 +342,20 @@ fn main() -> Result<()> {
let mut system = sysinfo::System::new_all();
system.refresh_processes();

if system.process_by_name("komorebi.exe").len() > 1 {
tracing::error!("komorebi.exe is already running, please exit the existing process before starting a new one");
std::process::exit(1);
let matched_procs = system.process_by_name("komorebi.exe");

if matched_procs.len() > 1 {
let mut shim_is_active = false;
for proc in matched_procs {
if proc.root().ends_with("shims") {
shim_is_active = true;
}
}

if !shim_is_active {
tracing::error!("komorebi.exe is already running, please exit the existing process before starting a new one");
std::process::exit(1);
}
}

// File logging worker guard has to have an assignment in the main fn to work
Expand Down

0 comments on commit d182839

Please sign in to comment.