Prevent multiple test-validators from using the same ledger directory
This commit is contained in:
parent
d2af09a647
commit
f3272db7f7
|
@ -1085,6 +1085,17 @@ dependencies = [
|
||||||
"ieee754",
|
"ieee754",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fd-lock"
|
||||||
|
version = "1.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a15bec795244d49f5ee3024bdc6c3883fb035f7f6601d4a4821c3d5d60784454"
|
||||||
|
dependencies = [
|
||||||
|
"failure",
|
||||||
|
"libc",
|
||||||
|
"winapi 0.3.8",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "feature-probe"
|
name = "feature-probe"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
|
@ -5096,6 +5107,7 @@ dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"console",
|
"console",
|
||||||
|
"fd-lock",
|
||||||
"indicatif",
|
"indicatif",
|
||||||
"libc",
|
"libc",
|
||||||
"log 0.4.11",
|
"log 0.4.11",
|
||||||
|
|
|
@ -14,6 +14,7 @@ base64 = "0.12.3"
|
||||||
clap = "2.33.1"
|
clap = "2.33.1"
|
||||||
chrono = { version = "0.4.11", features = ["serde"] }
|
chrono = { version = "0.4.11", features = ["serde"] }
|
||||||
console = "0.11.3"
|
console = "0.11.3"
|
||||||
|
fd-lock = "1.1.1"
|
||||||
indicatif = "0.15.0"
|
indicatif = "0.15.0"
|
||||||
log = "0.4.11"
|
log = "0.4.11"
|
||||||
rand = "0.7.0"
|
rand = "0.7.0"
|
||||||
|
|
|
@ -188,19 +188,28 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !ledger_path.exists() {
|
||||||
|
fs::create_dir(&ledger_path).unwrap_or_else(|err| {
|
||||||
|
eprintln!(
|
||||||
|
"Error: Unable to create directory {}: {}",
|
||||||
|
ledger_path.display(),
|
||||||
|
err
|
||||||
|
);
|
||||||
|
exit(1);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut ledger_fd_lock = fd_lock::FdLock::new(std::fs::File::open(&ledger_path).unwrap());
|
||||||
|
let _ledger_lock = ledger_fd_lock.try_lock().unwrap_or_else(|_| {
|
||||||
|
eprintln!(
|
||||||
|
"Error: Unable to lock {} directory. Check if another solana-test-validator is running",
|
||||||
|
ledger_path.display()
|
||||||
|
);
|
||||||
|
exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
let validator_log_symlink = ledger_path.join("validator.log");
|
let validator_log_symlink = ledger_path.join("validator.log");
|
||||||
let logfile = if output != Output::Log {
|
let logfile = if output != Output::Log {
|
||||||
if !ledger_path.exists() {
|
|
||||||
fs::create_dir(&ledger_path).unwrap_or_else(|err| {
|
|
||||||
eprintln!(
|
|
||||||
"Error: Unable to create directory {}: {}",
|
|
||||||
ledger_path.display(),
|
|
||||||
err
|
|
||||||
);
|
|
||||||
exit(1);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
let validator_log_with_timestamp = format!(
|
let validator_log_with_timestamp = format!(
|
||||||
"validator-{}.log",
|
"validator-{}.log",
|
||||||
SystemTime::now()
|
SystemTime::now()
|
||||||
|
|
Loading…
Reference in New Issue