Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Add `rad node restart` command
◌ CI pending Rūdolfs Ošiņš committed 9 months ago
commit afc0f21c62746bcfd4423dbb1acfb7552e146e60
parent a670b6e668761ea5893b7d343b4515b888712f14
2 pending (2 total) View logs
1 file changed +18 -0
modified crates/radicle-cli/src/commands/node.rs
@@ -35,6 +35,7 @@ Usage
    rad node status [<option>...]
    rad node start [--foreground] [--verbose] [<option>...] [-- <node-option>...]
    rad node stop [<option>...]
+
    rad node restart [<option>...]
    rad node logs [-n <lines>]
    rad node debug [<option>...]
    rad node connect <nid>[@<addr>] [<option>...]
@@ -116,6 +117,7 @@ pub enum Operation {
        timeout: time::Duration,
        count: usize,
    },
+
    Restart,
    Routing {
        json: bool,
        rid: Option<RepoId>,
@@ -145,6 +147,7 @@ pub enum OperationName {
    Config,
    Db,
    Events,
+
    Restart,
    Routing,
    Logs,
    Start,
@@ -186,6 +189,7 @@ impl Args for Options {
                    "events" => op = Some(OperationName::Events),
                    "logs" => op = Some(OperationName::Logs),
                    "config" => op = Some(OperationName::Config),
+
                    "restart" => op = Some(OperationName::Restart),
                    "routing" => op = Some(OperationName::Routing),
                    "inventory" => op = Some(OperationName::Inventory),
                    "start" => op = Some(OperationName::Start),
@@ -257,6 +261,7 @@ impl Args for Options {
            OperationName::Config => Operation::Config { addresses },
            OperationName::Db => Operation::Db { args: options },
            OperationName::Events => Operation::Events { timeout, count },
+
            OperationName::Restart => Operation::Restart,
            OperationName::Routing => Operation::Routing { rid, nid, json },
            OperationName::Logs => Operation::Logs { lines },
            OperationName::Start => Operation::Start {
@@ -317,6 +322,19 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
        Operation::Events { timeout, count } => {
            events::run(node, count, timeout)?;
        }
+
        Operation::Restart => {
+
            if node.is_running() {
+
                control::stop(node.clone(), &profile);
+
            }
+
            control::start(
+
                node,
+
                true,
+
                false,
+
                [].to_vec(),
+
                &PathBuf::from("radicle-node"),
+
                &profile,
+
            )?;
+
        }
        Operation::Routing { rid, nid, json } => {
            let store = profile.database()?;
            routing::run(&store, rid, nid, json)?;