Command and control

The command line interface

These instructions are for Linux. The restxctl script is utilized, which is created during install. For Windows instructions on how to start the server, please go here.

The restxctl script is located in your RESTx home directory; the directory you created when you downloaded and unpacked RESTx. restxctl can be run as non-root user and allows you to start/stop the server in various ways, to create and install new components or compile your Java component code.

Starting and stopping the server

Start server in the foreground, with output to the console.

  • % ./restxctl start
     
  • Or to start server in the background.
    % ./restxctl start -b
     
  • To stop the server run:
    % ./restxctl stop
    Or type CTL-C if the server runs in the foreground.
     
  • To restart a running server:
    % ./restxctl restart [-b]

The process PID is stored in restx.pid, while the logfile is restx.log. The server listens for HTTP requests on port 8001 by default. Use the -logfile <filename> option to specify an alternative log file location.

Creating new components

You can create a component template for the language of your choice with just a single command:

% ./restxctl component create MyTestComponent java

or

% ./restxctl component create MyTestComponent python
 
Here, 'MyTestComponent' is the name you would like to give your new component, while 'java' or 'python' indicates the language in which you want to write your component. Currently, these are the two supported languages. More will be added in the future.
The script prints the location of the new component file. By default, new components are created in certain standard component directories. If you would like to develop your component in different packages or locations, you can specify those with the 'create' command as well:
 

% ./restxctl component create MyTestComponent python mysrc/foo mymodule

As we can see, there are now two additional parameters. The first one to set the target directory in which the new component is created, the second one to indicate the module/package that his component is part of.

Enabling, disabling and listing components

Components can be individually enabled and disabled. When a component is disabled then any resources based on this component remain visible but cannot be used. When changing the enabled/disabled status of a component, a server restart is required before the changes take effect.

To disable a component:

% ./restxctl component disable MyComponent

To enable a component again:

% ./restxctl component enable MyComponent

Note that when a component is created, it is enabled by default.
 
You can see all known components, their status, language and module with the 'list' command:
 
% ./restxctl component list
 
Depending on your setup, you will get output similar to this:
 
	Component name                    Enabled   Language     Module
---------------------------------------------------------------------------------------------
CombinerComponent                 yes       python       restx.components.CombinerComponent
DatabaseAccess                    yes       python       restx.components.DatabaseAccess
Failover                          yes       python       restx.components.Failover
FooBar                            no        python       restx.components.FooBar
GsearchComponent                  yes       python       restx.components.GsearchComponent
LogFileComponent                  no        python       restx.components.LogFileComponent
_ResourceCreateForm               yes       python       restx.components._ResourceCreateForm
StorageComponent                  yes       python       restx.components.StorageComponent
TestComponent                     yes       java         org.mulesoft.restx.component
 

Deleting components

To permanently remove a component and all resources based on it, use the 'delete' command:

% ./restxctl component delete MyComponent

Warning: This operation cannot be undone. Remember that all associated resource definitions will also be deleted.

Listing associated resources for a component

To quickly see which resources are based on a particular component, use the 'resources' command:

% ./restxctl component resources MyComponent

As a result, you get a list of all specialized component resources as well as normal resources.

Compiling Java components

If you have created a Java component, you need to compile them before they can be used in the server. To do so, use this command: %./restxctl component compile