From 3284a61afd8b9825ba77bfadf72038edc6c22763 Mon Sep 17 00:00:00 2001 From: Anthony Keenan Date: Thu, 6 Sep 2018 09:37:04 +0100 Subject: [PATCH] CORDA-1755: Modify the node to run using picocli (#3872) * Modify Corda Node to use picocli * Make --sshd parameter actually work * * Some refactoring * Fixing the issue with the --confg-file parameter * Updating the tests * Restore original devMode behaviour * Update documentation * Add return code to network bootstrapper * Use the root jar for the shell alias for jars packaged with capsule * Update Corda jar description * Fix issue with logging not initialising early enough in node Make initLogging overridable Combine --verbose and --log-to-console options * Tidy up * Make sure all command line options are documented properly * Fix compilation error * Remove code that's no longer needed (single slash options no longer supported unless explicitly specified) * Remove comment * Remove pointless comment * Log commandline arguments * Address review comments * Address more review comments * Remove ConfigFilePathArgsParser * Remove some unused importss * Only display config when in dev mode * Force Ansi ON if on Windows else set to AUTO. * Make ExitCodes class open --- docs/source/running-a-node.rst | 79 ++++++-- node/build.gradle | 4 +- node/src/main/java/CordaCaplet.java | 8 - node/src/main/kotlin/net/corda/node/Corda.kt | 4 +- .../kotlin/net/corda/node/NodeArgsParser.kt | 142 ------------- .../net/corda/node/NodeCmdLineOptions.kt | 135 +++++++++++++ .../net/corda/node/internal/NodeStartup.kt | 132 +++++------- .../node/services/config/ConfigUtilities.kt | 13 +- .../net/corda/node/NodeArgsParserTest.kt | 189 ------------------ .../net/corda/node/NodeCmdLineOptionsTest.kt | 44 ++++ .../kotlin/net/corda/bootstrapper/Main.kt | 5 +- tools/cliutils/build.gradle | 3 + .../cliutils/ConfigFilePathArgsParser.kt | 25 --- .../net/corda/cliutils/CordaCliWrapper.kt | 66 ++++-- .../corda/cliutils/CordaVersionProvider.kt | 10 +- .../kotlin/net/corda/cliutils/ExitCodes.kt | 8 + .../cliutils/InstallShellExtensionsParser.kt | 10 +- 17 files changed, 382 insertions(+), 495 deletions(-) delete mode 100644 node/src/main/kotlin/net/corda/node/NodeArgsParser.kt create mode 100644 node/src/main/kotlin/net/corda/node/NodeCmdLineOptions.kt delete mode 100644 node/src/test/kotlin/net/corda/node/NodeArgsParserTest.kt create mode 100644 node/src/test/kotlin/net/corda/node/NodeCmdLineOptionsTest.kt delete mode 100644 tools/cliutils/src/main/kotlin/net/corda/cliutils/ConfigFilePathArgsParser.kt create mode 100644 tools/cliutils/src/main/kotlin/net/corda/cliutils/ExitCodes.kt diff --git a/docs/source/running-a-node.rst b/docs/source/running-a-node.rst index 14c6f91268..2caf9e64c5 100644 --- a/docs/source/running-a-node.rst +++ b/docs/source/running-a-node.rst @@ -47,22 +47,75 @@ Command-line options ~~~~~~~~~~~~~~~~~~~~ The node can optionally be started with the following command-line options: -* ``--base-directory``: The node working directory where all the files are kept (default: ``.``) +* ``--base-directory``, ``-b``: The node working directory where all the files are kept (default: ``.``). * ``--bootstrap-raft-cluster``: Bootstraps Raft cluster. The node forms a single node cluster (ignoring otherwise configured peer - addresses), acting as a seed for other nodes to join the cluster -* ``--config-file``: The path to the config file (default: ``node.conf``) -* ``--help`` + addresses), acting as a seed for other nodes to join the cluster. +* ``--clear-network-map-cache``, ``-c``: Clears local copy of network map, on node startup it will be restored from server or file system. +* ``--config-file``, ``-f``: The path to the config file. Defaults to ``node.conf``. +* ``--dev-mode``, ``-d``: Runs the node in developer mode. Unsafe in production. Defaults to true on MacOS and desktop versions of Windows. False otherwise. +* ``--help``, ``-h``: Displays the help message and exits. * ``--initial-registration``: Start initial node registration with Corda network to obtain certificate from the permissioning - server + server. +* ``--install-shell-extensions``: Installs an alias and auto-completion for users of ``bash`` or ``zsh``. See below for more information. * ``--just-generate-node-info``: Perform the node start-up task necessary to generate its nodeInfo, save it to disk, then - quit -* ``--log-to-console``: If set, prints logging to the console as well as to a file -* ``--logging-level <[ERROR,WARN,INFO, DEBUG,TRACE]>``: Enable logging at this level and higher (default: INFO) -* ``--network-root-truststore``: Network root trust store obtained from network operator -* ``--network-root-truststore-password``: Network root trust store password obtained from network operator -* ``--no-local-shell``: Do not start the embedded shell locally -* ``--sshd``: Enables SSHD server for node administration -* ``--version``: Print the version and exit + quit. +* ``--just-generate-rpc-ssl-settings``: Generate the ssl keystore and truststore for a secure RPC connection. +* ``--log-to-console``, ``--verbose``, ``-v``: If set, prints logging to the console as well as to a file. +* ``--logging-level <[ERROR,WARN,INFO,DEBUG,TRACE]>``: Enable logging at this level and higher. Defaults to INFO. +* ``--network-root-truststore``, ``-t``: Network root trust store obtained from network operator. +* ``--network-root-truststore-password``, ``-p``: Network root trust store password obtained from network operator. +* ``--no-local-shell``, ``-n``: Do not start the embedded shell locally. +* ``--on-unknown-config-keys <[FAIL,WARN,INFO]>``: How to behave on unknown node configuration. Defaults to FAIL. +* ``--sshd``: Enables SSH server for node administration. +* ``--sshd-port``: Sets the port for the SSH server. If not supplied and SSH server is enabled, the port defaults to 2222. +* ``--version``, ``-V``: Prints the version and exits. + +.. _installing-shell-extensions: + +Installing shell extensions +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Users of ``bash`` or ``zsh`` can install an alias and command line completion for Corda. Run: + +.. code-block:: shell + + java -jar corda.jar --install-shell-extensions + +Then, either restart your shell, or for ``bash`` users run: + +.. code-block:: shell + + . ~/.bashrc + +Or, for ``zsh`` run: + +.. code-block:: shell + + . ~/.zshrc + +You will now be able to run a Corda node from anywhere by running the following: + +.. code-block:: shell + + corda --