Starting and stopping

Starting and stopping a MarketGrid system and viewing the status of services.

mg command

The mg command is the main command used for the MarketGrid system.

> mg help
Usage: mg command [flags]

Main commands:
 $ mg start [scenario_name] [flags]
   starts MarketGrid services.
   scenario_name: (Optional) The name of the scenario to start
   flags: options to pass to services, in the form --service.option

 $ mg status
   displays the status of MarketGrid processes.

 $ mg stop [service_name]
   stops MarketGrid services (or a single service).
   service_name: (Optional) Name of a service to stop

Other commands:
 $ mg cycle
   removes deleted/expired records from shared memory.

 $ mg inspect [port]
   starts a web server for inspecting transaction logs and shared memory.
   port: (Optional) The port on which to listen

 $ mg restart [service_name]
   restarts MarketGrid services (or a single service).
   service_name: (Optional) Name of a service to restart

 $ mg run process_name [flags]
   runs a single process in the foreground..
   process_name: The name of the process to start
   flags: options to pass to the process

 $ mg scenarios
   lists available scenarios.

 $ mg test root [pattern]
   Executes test cases within a directory.
   root: Root directory containing test cases
   pattern: (Optional) Test case name pattern to match

Starting MarketGrid

Start from a scenario (text based files)

To see the list of available scenarios, use the mg scenarios command:

> mg scenarios
Available scenarios:
  test_data: Test data set
  equities_test_data_s: equities_test_data with small table sizes (requires ~250MB of memory)
  equities_test_data_m: equities_test_data with medium table sizes (requires ~1GB of memory)
  equities_test_data_l: equities_test_data with large table sizes (requires ~20GB of memory)

The system can then be started using any of the above scenarios. Each scenario has an associated text based dataset, as well as a configuration file specifying which services should be started such as the UI server, individual Market Database processes, Kafka services, or other interfaces.

> mg start test_data
Selected scenario: test_data
★ Starting services: matching_engine, transaction_server, ui_server, nginx, rdb, hdb, gateway, discovery
★ Running task: GenerateKeyPair
★ Running task: LoadTsvDirectory
* Running task: GenerateMdbProcessCsv
...

Starting MarketGrid from a transaction log

After starting up MarketGrid, the trading engine will begin to write a transaction log to disk. Any transaction log can also be used to start the system and recover it to a particular state. These can be found in the logs/transactions directory.

To start MarketGrid from a transaction log, use the --matching_engine.load option:

mg start --matching_engine.load ${log_file}

where ${log_file} is the relative path to the transaction log.

Viewing service status

Once the startup is complete, you can verify the operational status of the system.

>> mg status
Selected scenario: test_data
service              image_name   pid      start_time                 running
─────────────────────────────────────────────────────────────────────────────
matching_engine      te_engine    288604   2020-10-28T23:54:08.508Z   running
transaction_server   te_tserver   288605   2020-10-28T23:54:08.511Z   running
ui_server            node         288607   2020-10-28T23:54:08.516Z   running
nginx                nginx        288615   2020-10-28T23:54:08.524Z   running
rdb                  q            288617   2020-10-28T23:54:08.531Z   running
hdb                  q            288620   2020-10-28T23:54:08.537Z   running
gateway              q            288622   2020-10-28T23:54:08.542Z   running
discovery            q            288625   2020-10-28T23:54:08.549Z   running

Stopping

To stop the entire system:

mg stop

You can also stop an individual service by specifying the service name (matching the name as shown in mg status output):

mg stop rdb