| Home | Articles | JSAP | | Lab | Retired | Contact | About |
|
| Nailgun | News | Background | | API | Protocol | Changelog | License | Download | |
|
|
|
Nailgun Quick StartThis quick start assumes enough familiarity with Java to manage your classpath. A better manual is needed - writing code isn't the only way to contribute to open source! (hint hint).
That's it. To shut down the server, use the ng client again. The command is "ng ng-stop". Some statistics will be displayed when Nailgun shuts down. AliasesYou can avoid a lot of typing by defining aliases for your classnames. Make sure the Nailgun server is still running, and set an alias via "ng ng-alias (aliasName) (aliasClass)". Replace (aliasName) with a short name of your choosing, and (aliasClass) with the fully qualified classname of your class. You can have multiple aliases for the same class. You'll see why this is useful later. To see what aliases are currently defined, use "ng ng-alias" with no arguments. Symbolic LinksIf you find that aliases still require too much typing, you can create a symbolic link for the ng client. The name you give the link will be interpreted as the command or classname. You can use either an alias or a fully qualified classname for your symlink. NailsFor MUCH greater functionality, you can provide an additional method in your class:
public static void nailMain(NGContext context) {
// ...
}
If you provide such a method, congratulations. You've written a Nail. The context provides a great deal of information about the connection, including the client's environment variables, working directory, IP address, and lots more - including the command that was issued by the client (remember what I said above about multiple aliases pointing to the same class? Look at the Stack example to see how you can take advantage of this). For more details, see the API. If your class happens to provide both nailMain and main, nailMain will be called by the Nailgun server. Overriding DefaultsBy default, the Nailgun server listens on port 2113, and the client connects to localhost on that same port. To run the server on a different port, include the port as an argument when you launch the server. That is, to run the server on port 8765, launch Nailgun with "java -server com.martiansoftware.nailgun.NGServer 8765". To bind the server to a specific address, specify the address as an argument when you launch the server. That is, to run the server only on the loopback address, launch Nailgun with "java -server com.martiansoftware.nailgun.NGServer 127.0.0.1". To combine the above options, specify both separated by a colon. That is, to run the server only on the loopback address on port 8765, launch Nailgun with "java -server com.martiansoftware.nailgun.NGServer 127.0.0.1:8765". Specify port 0 to have NGServer select a port automatically. The selected port number will be displayed on System.out. The client presents a couple more options. First, the server and port can be individually set via the NAILGUN_SERVER and NAILGUN_PORT environment variables. Both the defaults and the environment variables can be overridden via command line arguments to the ng client. The arguments are "--nailgun-server" and "--nailgun-port", and they can be placed anywhere on the ng command line. They will not be passed as command line arguments to your Nails. So to shutdown the server you just started on port 8765, issue the command "ng --nailgun-port 8765 ng-stop" or "ng ng-stop --nailgun-port 8765". Embedding NailgunYou don't have to run Nailgun as a standalone server; it's very easy to create an NGServer object and start it within your own application in order to provide command-line interaction with your running app. See the API for more details. Builtin NailsNailgun comes with a few basic nails that help run the server. These nails, like the rest of Nailgun, should be considered early alpha quality - they are not robust if you specify invalid arguments, and their usage, or even existence, may change in the future. These nails have aliases by default.
Example NailsNo aliases are created for these nails by default, and they are not included in the regular nailgun .jar file. To use these examples, be sure to include the nailgun-examples-0.7.jar file in your server's classpath!
|
|