Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adex tool was introduced #1729

Merged
merged 78 commits into from
Apr 10, 2023
Merged

adex tool was introduced #1729

merged 78 commits into from
Apr 10, 2023

Conversation

rozhkovdmitrii
Copy link

@rozhkovdmitrii rozhkovdmitrii commented Mar 22, 2023

DO NOT FORGET TO SQUASH COMMITTS ON MERGE

adex command line utility was introduced that supplies

Commands: init, start, stop, status

@rozhkovdmitrii rozhkovdmitrii marked this pull request as ready for review March 22, 2023 10:01
@rozhkovdmitrii
Copy link
Author

@shamardy @ozkanonur @borngraced
Guys, I'm happy to introduce the version 0.1.0

@rozhkovdmitrii rozhkovdmitrii changed the title Feature adex utility was introduced adex tool was introduced Mar 22, 2023
@rozhkovdmitrii rozhkovdmitrii marked this pull request as draft March 22, 2023 10:26
@onur-ozkan onur-ozkan added the in progress Changes will be made from the author label Mar 22, 2023
Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great implementation :)

I have a few suggestions/notes from my first review iteration:

CHANGELOG.md Outdated Show resolved Hide resolved
mm2src/adex_cli/Cargo.toml Outdated Show resolved Hide resolved
mm2src/adex_cli/src/scenarios/init_coins.rs Outdated Show resolved Hide resolved
mm2src/adex_cli/src/log.rs Show resolved Hide resolved
mm2src/adex_cli/src/scenarios/init_coins.rs Outdated Show resolved Hide resolved
mm2src/adex_cli/src/scenarios/init_coins.rs Outdated Show resolved Hide resolved
mm2src/adex_cli/src/scenarios/init_mm2_cfg.rs Outdated Show resolved Hide resolved
mm2src/adex_cli/src/scenarios/mm2_proc_mng.rs Show resolved Hide resolved
Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!
I have a few comments/questions for my first review :)

mm2src/adex_cli/src/scenarios/init_mm2_cfg.rs Outdated Show resolved Hide resolved
mm2src/adex_cli/src/scenarios/init_mm2_cfg.rs Outdated Show resolved Hide resolved
mm2src/adex_cli/src/scenarios/init_mm2_cfg.rs Show resolved Hide resolved
mm2src/adex_cli/src/scenarios/init_mm2_cfg.rs Outdated Show resolved Hide resolved
mm2src/adex_cli/src/scenarios/init_mm2_cfg.rs Show resolved Hide resolved
mm2src/adex_cli/src/scenarios/init_mm2_cfg.rs Show resolved Hide resolved
mm2src/adex_cli/src/scenarios/init_mm2_cfg.rs Show resolved Hide resolved
mm2src/adex_cli/src/scenarios/mm2_proc_mng.rs Outdated Show resolved Hide resolved
mm2src/adex_cli/src/scenarios/mm2_proc_mng.rs Outdated Show resolved Hide resolved
Copy link
Member

@borngraced borngraced left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I have couple questions and some questions

mm2src/adex_cli/src/scenarios/mm2_proc_mng.rs Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
mm2src/adex_cli/src/scenarios/init_mm2_cfg.rs Outdated Show resolved Hide resolved
@rozhkovdmitrii rozhkovdmitrii requested review from borngraced and removed request for onur-ozkan March 27, 2023 05:38
@DeckerSU
Copy link
Collaborator

DeckerSU commented Apr 6, 2023

Hm, I see the difference in original Cargo.lock, of coarse it should be solved

Yes, I mentioned exactly these differences, nothing else. Sorry, maybe I wasn't so clear.

@rozhkovdmitrii
Copy link
Author

@DeckerSU
rolled back

Copy link
Collaborator

@DeckerSU DeckerSU left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. mm2 binary exists, but we accidentally did chmod -x mm2 on it.
  2. After ./adex-cli start user 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.

@onur-ozkan
Copy link
Member

onur-ozkan commented Apr 7, 2023

You just have avoid writing Successfully started: "mm2", forked pid: $id when mm2 is not an executable. @rozhkovdmitrii

@rozhkovdmitrii
Copy link
Author

rozhkovdmitrii commented Apr 7, 2023

You just have avoid writing Successfully started: "mm2", forked pid: $id when mm2 is not an executable. @rozhkovdmitrii

Sure, I know, thank you )
The matter is right after fork the program releases terminal even if that is the main process and I want to save the output straight

Peek 2023-04-07 20-13

@rozhkovdmitrii
Copy link
Author

rozhkovdmitrii commented Apr 7, 2023

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:

1. `mm2` binary exists, but we accidentally did `chmod -x mm2` on it.

2. After `./adex-cli start` user will see the following message:

...

@DeckerSU

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:?}");

image

@rozhkovdmitrii
Copy link
Author

rozhkovdmitrii commented Apr 7, 2023

Found more deliberate decision using fork and setsid together instead of daemon. Works well, no ugly things in source code
to: @DeckerSU
cc: @ozkanonur

Diff from last review

Copy link
Collaborator

@DeckerSU DeckerSU left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Let's imagine user already have started instance of mm2 from some other folder.
  2. In folder with adex-cli he have mm2 file without rights on execution (chmod -x mm2).
  3. After ./adex-cli start user will see the message Successfully 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);

@rozhkovdmitrii
Copy link
Author

...
std::mem::forget(child_process);

println!("Started child process with PID {}", pid);

@DeckerSU, to tell you the truth, using std::mem::forget was not obvious. Thank you for great decision ), this one is the best of coarse!

Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes @rozhkovdmitrii! Changes since my last review looks good.

@ca333 ca333 merged commit a0ee6b6 into KomodoPlatform:dev Apr 10, 2023
@ca333 ca333 mentioned this pull request Apr 10, 2023
ca333 added a commit that referenced this pull request Apr 11, 2023
adex-cli command line utility was introduced that supplies commands: init, start, stop, status #1729
CI/CD workflow logics are improved #1736
Project root is simplified/refactored #1738
Created base image to provide more glibc compatible pre-built binaries for linux #1741
Set default log level as "info" #1747
@rozhkovdmitrii
Copy link
Author

If we want CLI to work with remote nodes, then yes it should work over HTTP

Should be HTTPS, else the rpc password is sent in cleartext over internet. There is an issue about this #1324 and i think it's an easy task.

#1873

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants