adex tool was introduced#1729
adex tool was introduced#1729ca333 merged 78 commits intoGLEECBTC:devfrom rozhkovdmitrii:feature-1682-introduce-adex
Conversation
…m2 and atomic swap protocol
|
@shamardy @ozkanonur @borngraced |
onur-ozkan
left a comment
There was a problem hiding this comment.
Great implementation :)
I have a few suggestions/notes from my first review iteration:
…-adex # Conflicts: # Cargo.lock # mm2src/common/Cargo.toml
…-adex # Conflicts: # CHANGELOG.md
shamardy
left a comment
There was a problem hiding this comment.
Great work!
I have a few comments/questions for my first review :)
borngraced
left a comment
There was a problem hiding this comment.
Great work! I have couple questions and some questions
Oh I totally misunderstood, sorry |
|
@DeckerSU, let me comment on it, please.
Hm, I see the difference in original Cargo.lock, of coarse it should be solved cc: @ozkanonur |
| let program = mm2_binary | ||
| .file_name() | ||
| .map_or("Undefined", |name: &OsStr| name.to_str().unwrap_or("Undefined")); | ||
| let Some(program) = mm2_binary.file_name() else { |
There was a problem hiding this comment.
I guess else branch of let-else statement here will never work ... bcz mm2_binary.file_name() will always return Some("mm2") or Some("mm2.exe") ... depends on platform, whether the file actually exists or not.
There was a problem hiding this comment.
I know it, that is just paranoic mode. If we are prone to not use any forms of unwrap or extend we will never meet any panic
There was a problem hiding this comment.
Please consider using expect or panic under unwrap_or_else
Yes, I mentioned exactly these differences, nothing else. Sorry, maybe I wasn't so clear. |
DeckerSU
left a comment
There was a problem hiding this comment.
Seems you are missed / did not pay attention to few recommendations in #1729 (review) , related to the "Matching with Fork::Parent should not be considered as a successful launch".
Let's imagine the following case:
mm2binary exists, but we accidentally didchmod -x mm2on it.- After
./adex-cli startuser will see the following message:
Successfully started: "mm2", forked pid: 579956
thread 'main' panicked at 'Failed to execute process: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }', src/scenarios/mm2_proc_mng.rs:117:30
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Errors and reports about a successful start at the same time mislead.
In all other aspects it looks good to me.
|
You just have avoid writing |
Sure, I know, thank you ) |
done cc: @ozkanonur P.S: if I used something like this the output would make the output messy if let Ok(Fork::Child) = daemon(true, true) {
command.output().expect("Failed to start: {program:?}");
exit(1);
};
info!("Successfully started: {program:?}"); |
|
Found more deliberate decision using fork and setsid together instead of daemon. Works well, no ugly things in source code |
DeckerSU
left a comment
There was a problem hiding this comment.
The look of it has improved, but there is still a potential for a report of a “successful start” even if the outcome was a failure:
- Let's imagine user already have started instance of
mm2from some other folder. - In folder with
adex-clihe havemm2file without rights on execution (chmod -x mm2). - After
./adex-cli startuser will see the messageSuccessfully started: "mm2", but in real - nothing is started.
Also, can you explain why you chose to use fork() to launch the mm2, rather than simple spawn new process and "detach"? What was your thought process behind this decision? Just curious to know.
use std::process::Command;
let child_process = Command::new("my_child_process_binary")
.args(&["arg1", "arg2"])
.spawn()
.expect("Failed to start child process");
// detach the child process
let pid = child_process.id();
std::mem::forget(child_process);
println!("Started child process with PID {}", pid);
@DeckerSU, to tell you the truth, using |
shamardy
left a comment
There was a problem hiding this comment.
Thanks for the fixes @rozhkovdmitrii! Changes since my last review looks good.


DO NOT FORGET TO SQUASH COMMITTS ON MERGE
adexcommand line utility was introduced that suppliesCommands:
init,start,stop,status