# Web Application Server

## Description

The Web application server is a threaded server which provides services to the Web UI, as well as supporting the tagger broker. By default, the application server also starts up a command loop which allows the user to start up and shut down various portions of the application. The application server supports CGI access for some services, and XML-RPC for others. The service API is intended to be internal; it will be documented at a later point.

Note: the Web application server inventories the tagger models it makes available in file mode at startup time. If you build a model after you start the Web server, the Web server won't know about that model until you restart it. (This condition does not apply to workspaces.)

### The command loop

When you start up the Web server, and it's running a command loop, you see something like this:

Web server started on port 7801.Web server command loop. Commands are:exit       - exit the command loop and stop the Web serverloopexit   - exit the command loop, but leave the Web server runningtaggerexit - shut down the tagger service, if it's runningrestart    - restart the Web serverws_key     - show the workspace keyhelp, ?    - this messageWorkspace key is w65gABlWFKYSdZwXCHaspyhW0DySP7ZWCommand:

These commands should be self-explanatory. The command that you're most likely to use is "ws_key", which prints out the workspace key that the Web server knows. The workspace security documentation explains the importance of this key.

## Usage

### Example 2

To start up the Web server on port 7806, but only allow connections from the local host:

Unix:% $MAT_PKG_HOME/bin/MATWeb --port 7806 --localhost_onlyWindows native:> %MAT_PKG_HOME%\bin\MATWeb.cmd --port 7806 --localhost_only ### Example 3 To start up the Web server on the default port, but write the status messages to different files: Unix:%$MAT_PKG_HOME/bin/MATWeb --access_log ./web_access.log --error_log ./web_error.log \--tagger_log ./web_tagger.log --noscreenWindows native:> %MAT_PKG_HOME%\bin\MATWeb.cmd --access_log %CD%\web_access.log --error_log %CD%\web_error.log \--tagger_log %CD%\web_tagger.log --noscreen

Without the --noscreen flag, the Web server messages will be printed both to the files and to standard output.

### Example 4

On Unix, to start up the Web server as a Unix cron job, saving logs for the previous 7 days in /etc/MAT/logs, and restarting each midnight, enter this command line in your crontab, if MAT_PKG_HOME is /usr/MAT:

/usr/MAT/bin/MATWeb --access_log /etc/MAT/logs/web_access.log \--error_log /etc/MAT/logs/web_error.log \--tagger_log /etc/MAT/logs/web_tagger.log --noscreen \--no_cmdloop --midnight_restart --log_rotation_count 7

Caution: this mode is very, very lightly tested.

### Example 5

Let's say you want to distribute access to some MAT workspaces to a range of annotators on a variety of machines, but you don't want to force them to remember a complex workspace key or pathname. You can specify the workspace key and the container directory for the workspaces on the command line when you start up MATWeb. (Be sure to distribute the workspace key to your annotators in a secure manner, since it's our only means of security at the moment.)

Unix:% \$MAT_PKG_HOME/bin/MATWeb --workspace_key my_annotator_key \--workspace_container_directory /path/to/dir/containing/workspacesWindows native:> %MAT_PKG_HOME%\bin\MATWeb.cmd --workspace_key my_annotator_key \--workspace_container_directory C:\path\to\dir\containing\workspaces

### Example 6

Let's say you want to start up the Web server as a cron job, but you don't want all the verbosity in example 4, and you also want to specify the workspace key and the workspace container directory, and you prefer a log rotation of 5:

/usr/MAT/bin/MATWeb --as_service /etc/MAT/logs \--workspace_key my_annotator_key \--workspace_container_directory /path/to/dir/containing/workspaces \--log_rotation_count 5

This is the same as if you had specified

/usr/MAT/bin/MATWeb --midnight_restart --allow_remote_workspace_access \--supersede_existing_server --noscreen --no_cmdloop \--access_log /etc/MAT/logs/access.log --error_log /etc/MAT/logs/error.log \--tagger_log /etc/MAT/logs/tagger.log --output_log /etc/MAT/logs/output.log \--workspace_key my_annotator_key \--workspace_container_directory /path/to/dir/containing/workspaces \--log_rotation_count 5