rust testnet cli tool#117
Conversation
| private_keys: if self.node_keys.is_empty() { | ||
| None | ||
| } else { | ||
| Some(self.node_keys.clone()) | ||
| }, |
There was a problem hiding this comment.
We should be able to directly use Option<T> for the node_keys:
#[clap(long = "node-keys")]
pub node_keys: Option<Vec<String>>,
Which will allow this simplification
| private_keys: if self.node_keys.is_empty() { | |
| None | |
| } else { | |
| Some(self.node_keys.clone()) | |
| }, | |
| private_keys: self.node_keys.clone(), |
| let shell_cmd = format!( | ||
| "nohup {} > {} 2>&1 & echo $! > {}", | ||
| cmd, | ||
| log_file_path.display(), | ||
| pid_file.display() | ||
| ); | ||
|
|
||
| Command::new("sh") | ||
| .arg("-c") | ||
| .arg(&shell_cmd) | ||
| .spawn() | ||
| .context("Failed to spawn emerald process")?; |
There was a problem hiding this comment.
Any reason we can't spawn and retrieve the using something like:
Command::new(cmd)
...
.spawn()?;
let pid = child.id();
And write pid to the pid_file?
There was a problem hiding this comment.
I tried that and the parent pid stayed attached to the child process and then when I tried to kill one single child process the process was bricked and sat in the stack...it kept happening and I couldnt find a solution. Given the short deadline I opted to just use a shell to spawn and move on.
It should be fixed that way eventually, I just didnt have the time or capacity.
There was a problem hiding this comment.
Actually it's a bit more tricky, I had to revert that commit
This reverts commit 6299e7c.
| node_home.display() | ||
| )); | ||
| } | ||
|
|
There was a problem hiding this comment.
TODO: make sure that the node is not already started
Testnet tool to replace using docker/Make