gx Setup

gx is Grainite's CLI tool that makes it convenient and easy to develop applications on Grainite.

If you haven't already, follow the Quickstart with Docker instructions to install the client package and Grainite docker image.

Before you begin developing WordCount, there is some optional minimal setup required for GX that will make it easier to use. Run gx to view the available functionality offered by the tool:

$> gx
[INFO] /home/azureuser/.gx file not found... Creating file.

[SUCCESS] Created /home/azureuser/.gx

Usage:

Perform Grainite related actions.

gx [-hV] [-c[=<YAML config>]] [--gxFile=Use the given properties file instead of the one at {user.
   home}/.gx.] [COMMAND]

Options:
  -c, --config[=<YAML config>]
                  Path to YAML config file.
                  If an existing YAML config file exists in the current directory,that YAML file is
                    used automatically.
      --gxFile=Use the given properties file instead of the one at {user.home}/.gx.

  -h, --help      Show this help message and exit.
  -V, --version   Print version information and exit.

Commands:
  gen      Generate java classes and methods
  config   Get and set gx properties.
  cleanup  Cleanup and restart server.
  load     Load the app configuration into Grainite.
  log      Prints log messages generated by handlers for the given application.
  start    Start a Grainite docker container.
  stop     Stop and remove a local Grainite docker container.
  table    Table related actions.
  topic    Topic related actions

gx searches for a config file - $HOME/.gx at runtime. If the file doesn't exist, it is created automatically.

You can run the following command to view all the config options in the config file.

$> gx config
Running gx with options:
         Host: null
   Admin Port: null
         Port: null
 Updater Port: null
Quay username: null
   Quay token: null

[INFO] You can either use gx config <property_name> <value> to set properties
Or you can directly edit: /home/ubuntu/.gx

For this tutorial, you will set the host to the Grainite server IP address. This will allow us to run commands without specifying the IP address repeatedly. You can run the following command to set the host (Replace <GRAINITE SERVER IP> with the IP address of the Grainite server that was provided to you).

$> gx config host <GRAINITE SERVER IP>

[SUCCESS] Updated host in config file.

Last updated