Fabric  0.2.1
Running Fabric programs

This guide demonstrates how to run a Fabric program. As a running example, we will use a worker named valinor, with /opt/fabric as the application home. The commands given are relative to the Fabric installation directory.

From the command line

The following command starts the worker, executes the class hello.Main, and shuts down the worker. If the worker is already running, then the command attaches to the already-running worker and executes hello.Main from within that instance.

$ bin/fab --jvm-cp /path/to/classes --app-home /opt/fabric \
--name valinor hello.Main

The --jvm-cp option specifies a path containing the (non-mobile) class hello.Main and any non-mobile classes it uses.

To execute a mobile class, specify the class's codebase-relative name. For example,

$ bin/fab --app-home /opt/fabric --name valinor \
fab://helloStore/35/hello.Main

From the worker shell

If a class name is not given when starting a worker, then the worker starts idle and the user is given a worker shell:

$ bin/fab --app-home /opt/fabric --name valinor
Worker started
valinor>

Stores also have worker shells for their colocated worker:

$ bin/fab-store --app-home /opt/fabric --name valinor
Worker started
Store started
valinor>

To execute a non-mobile class from within the worker, simply enter the class's name into the shell:

valinor> hello.Main
Hello, world!
valinor>

The worker must have the requisite non-mobile classes on its class path, as specified by the --jvm-cp command-line option when starting the worker.

To execute a mobile class, enter the class's codebase-relative name:

valinor> fab://helloStore/35/hello.Main
Hello, world!
valinor>