The tc Server Command Line Interface

This section includes the following topics:

Overview of the tcsadmin Command-Line Interface

SpringSource tc Server provides a command-line interface (CLI) called tcsadmin that you can use to perform a subset of tc Server configuration and application deployment tasks. You can use the CLI to configure and manage both single tc Server instances or groups of tc Servers.

The tcsadmin CLI is the script version of the HTML-based AMS tool. When you run the various CLI commands, you must specify an AMS server using its hostname and port; this means means that you must install the AMS component of tc Server in order to use the CLI.

You can use tcsadmin to perform the following tasks; all tasks are within the context of a particular AMS server:

When you use the tcsadmin CLI to perform application management and configuration operations for a group of tc Server instances, the CLI performs the operations sequentially and synchronously. For example, if you deploy a Web application to a group of tc Server instances, the CLI deploys the app to one of the server instances, waits for success, and only then deploys the application to another server in the group.

Any user configured to access the AMS UI console can also use the tcsadmin CLI. Additionally, all role-based access is honored for all tc Server operations, including server configuration, application management, and server control.

Tips for Windows Users

In this documentation, it is assumed that you are running the tcsadmin command-line interface on a Unix platform. If, however, you are running on Windows, the following changes to the documentation apply:

Downloading the tc Server Command-Line Interface

You must download the tc Server command-line interface binaries onto each computer on which you want to run it, as described in the following procedure:

  1. On the computer on which you want to download and install the tc Server command-line interface, invoke the AMS administration console in a browser. See the Getting Started with the AMS Console link in the left frame of the Getting Started with tc Server guide for details.

  2. Click the Administration link at the top of the main AMS console page.

  3. In the Plugins section, click the tc Server Command-line Interface link.

  4. Click the springsource-ams-scripting-client.zip link and save the ZIP file to a temporary directory on your computer.

  5. Unzip the file to the directory of your choice.

  6. The tcsadmin.sh (Unix) and tcsadmin.bat (Windows) scripts are located in the springsource-ams-scripting-client-version/bin directory, where version refers to a version string, such as 2.0.0.RC3.

General Syntax of the tcsadmin Command-Line Interface

Use the following syntax when using the tcsadmin command-line interface:

tcsadmin.sh|bat command options connection-parameters

where:

The following example shows how to start an application called myApp that is deployed to the tc Server group called Group1.

prompt$ ./tcsadmin.sh start-application --groupname=Group1 --application=myApp 

In the example, the command is start-application and the options are --groupname=Group1 and --application=myApp. Because there are no connection parameters specified at the command-line, it can be assumed that either the user running the command has created a user.home/.ams/client.properties file, or the default values of the connection parameters are adequate.

List of Available Commands

The following table lists all the available tcsadmin commands, along with the type of command and a brief description. The commands are broken into the following four types:

Click on the name of the command in the table for complete reference, including its associated options and examples.

Command Description Type
list-servers Lists all servers of type SpringSource tc Server 6.0 in the AMS inventory. Inventory
modify-server Changes the name or description of an existing tc Server instance. Inventory
list-groups Lists all tc Server groups in the AMS inventory. Inventory
create-group Creates a new tc Server group. Inventory
add-server-to-group Adds a tc Server to an existing group. Inventory
remove-server-from-group Removes a tc Server instance from a group. Inventory
delete-group Deletes an existing tc Server group. Inventory
list-applications List applications deployed to a tc Server instance or group and return their status. Application Management
deploy-application Upload and deploy an application to a tc Server instance or group from a local or remote file system. Application Management
start-application Start an application that has been previously deployed to a tc Server instance or group. Application Management
stop-application Stop an application that has been previously started. Application Management
reload-application Reload an application currently deployed to a tc Server instance or group. Application Management
undeploy-application Undeploy an application that is currently deployed to a tc Server instance or group. Application Management
put-file Modifies the configuration of a tc Server instance or each member of a tc Server group. Configuration
get-file Downloads the configuration of a tc Server instance to a file. Configuration
list-jvm-options Lists the JVM options for a single tc Server instance. Configuration
set-jvm-options Sets the JVM options for a tc Server instance or group. Configuration
start Starts a tc Server instance or group. Control
stop Stops a tc Server instance or group. Control
restart Restarts a tc Server instance or group. Control

Connection Parameters

The tc Server command-line interface must connect to an AMS server to perform the work associated with a particular command. This means that each time you use the CLI, you must specify connection parameters that indicate the particular AMS server to which you want to connect.

You can specify these parameters on the command-line. You can also create a user.home/.ams/client.properties file that lists the parameters and their values to avoid having to specify the connection parameters with every command, where user.home refers to the home directory of the user running the command-line interface. NOTE that the .ams directory name starts with a dot. On Windows, the home directory of a user is c:\Documents and Settings\<user_name>.

Parameters specified at the command-line always take precedence over the client properties file; if the CLI does not find any value for a parameter, either at the command-line or in the client properties file, it uses the default value.

The following table lists these connection parameters and their default values:

Parameter Description Default Value
--host=hostname Specifies the hostname of the computer that hosts the AMS server. If you are executing the tc Server CLI on the same computer on which AMS is running, you can specify localhost. localhost
--port=portnumber Specifies the TCP/IP port number to which the AMS server listens. 7080
--user=username The name of the user that the CLI uses to connect to the AMS server. This user can be any user configured to use the AMS UI. All role-based access is honored. hqadmin
--password=password The password of the user that the CLI uses to connect to the AMS server. hqadmin
--secure Specifies that you want the CLI to connect to the AMS server using a secure connection (SSL). This connection parameter does not take a value when specified at the command-line. Parameter does not take a value when specified at the command-line. If you do not specify the parameter, the CLI connects using a non-secure connection.

The following example shows how to use these parameters on the command-line:

prompt$ ./tcsadmin.sh list-servers --host=localhost --port=7081 \
         --user=tc_user --password=super_secret --secure 

In the example, the CLI connects to an AMS server on the same computer on which the CLI is running. The AMS server is listening at the TCP/IP port 7081. The username and password of the user connecting to the AMS server are tc_user and super_secret, respectively. The CLI connects to the AMS server using SSL.

If you want to specify the same parameters in a file to avoid specifying them at the command line, you must create a file called client.properties in a .ams sub-directory of the home directory of the user running the CLI. The following example shows the structure of this file using the parameter values specified above:

host=localhost
port=7081
user=tc_user
password=super_secret 
secure=true

NOTE: Even though the --secure parameter does not take a value at the command line, it does take a Boolean value in the client.properties file: true to enable a secure connection, false otherwise.

The following example shows the same command from above, but without the connection parameters; the CLI reads the values from the user.home/.ams/client.properties file:

prompt$ ./tcsadmin.sh list-servers 

It is assumed in the remainder of the documentation that you have created a client.properties file that contains the connection parameters; this is so sample usage of the server configuration and application management commands is easier to read.

Using Special Characters as Parameter Values

Sometimes it is necessary to use special characters, such as a space or a meta character, as part of a parameter value. The following guidelines describe how to use these special characters:

Group Command Behavior

You can run many of the tcsadmin commands against either a single tc Server instance or a group of tc Server instances. The following guidelines describe the behavior of commands if you run then against a group and a failure occurs:

Exit Codes

Each time you execute tcsadmin, the script always returns an exit code that indicates the success or failure of the particular command you just ran. The script also outputs a descriptive status message to STDOUT.

The exit code for success is always 0; the exit code for failure is a non-zero positive integer. Typically, the failure exit code is 1 if a single failure happened. However, because some tcsadmin commands run against a tc Server group, the command might succeed for some tc Server instances in the group but fail for others. In this case, the exit code will equal the number of failures.

The detailed reference information for each tcsadmin command includes the expected exit codes for that particular command.

Getting Help

Use the following commands to get help about a particular command or the list of available commands:

prompt$ ./tcsadmin.sh help

The help command lists all the available commands along with their parameters.

prompt$ ./tcsadmin.sh command --help

Use the --help parameter with any specific command to get detailed information about that command. The following example shows how to get detailed information about the list-applications command:

prompt$ ./tcsadmin.sh list-applications --help