Downloading and installing the Code Rally race simulation server
Running your own version of the race simulation server, instead of racing on our cloud servers, allows you to have your own leaderboard, your own server settings, and lets you see what is happening on the server side of a code rally race. These instructions assume that you have already installed the Code Rally Client as shown in this guide.
Installing when using Eclipse
Open your Eclipse install and change the perspective to the "Java EE" perspective (Window> perspective> open perspective> Java EE). During the previous install steps you will have installed a WebSphere Liberty server - this should be visible under the "servers" view. We will be installing the race simulation server onto that server.
- Firstly we want to import the Code Rally server into Eclipse - right-click in the "project explorer" box and choose import> WAR file. Navigate to the CodeRallyWeb.war that you downloaded above and choose to import it (it does not need to be in an EAR project, so you can untick the option to add it to an EAR).
- Once it is imported click and drag the project onto the WebSphere Liberty server in the servers view. This will deploy the application onto the server.
- Open the server configuration by clicking the twisty next to the Liberty server in the servers view, select "server configuration". This will open the server.xml editor - in the list of configuration elements on the left hand side select "Feature Manager" - on the right hand side you will see a list of features - click on "add" next to the list in the upper right and find a feature called "websocket-1.1" - add that to the list, save and close the server.xml editor.
- Start the server by right-clicking on it and choosing start - this will start the race simulation server, which will be available on http://localhost:9080/CodeRallyWeb - if you can visit that location in your web browser it will tell you the information needed to connect to the server from your Code Rally client for running races.
- If you want others to be able to race on this server, you need to go back into the server.xml editor, and select the "HTTP Endpoint" element in the list of elements - in there you need to change the entry for "Host" from "localhost" to "*" (that's an asterisk, with no quotes). This will let other computers connect to the server. Save the changes and close the server.xml editor.
- For people to be able to connect to the server running on your machine you will need to find out your IP address - if they're connecting from the same network this is pretty simple, but if they are connecting from other locations then you will need to find both your external IP address, and how to do port forwarding on your router - the default port for a WebSphere Liberty server is 9080 so you can either change that, or set your router to forward requests to port 9080 to your computer.
Alternative Instructions: How to install a Code Rally Server from the Windows Command Prompt (or Linux/Unix Terminal)
Use these instructions to download and install a Liberty server, add the Code Rally EAR to the server, and configure the Liberty configuration file (server.xml). These instructions are written for a Windows user; for Linux users the commands are roughly equivalent, just replace the Windows path with the path to your home directory.
A. Install Liberty
1. Download Liberty Profile Beta Runtime from WASdev. (https://developer.ibm.com/wasdev/downloads/). As of August 1st, 2014, the Beta release of Liberty is required for the server, as it relies on WebSocket support, which is new in the Beta versions of Liberty.
- The download will have a name like 'wlp-beta-runtime-2014.7.0.0.jar'
2. Create a new Liberty install directory, and move the downloading JAR file into the directory (for example, C:\Liberty).
3. Go into the c:\Liberty directory ('CD c:\Liberty') and run 'java -jar wlp-beta-runtime-2014.7.0.0.jar'
4. Accept the license terms that appear, and hit enter when prompted for a target installation directory (this will use the current directory)
5. Liberty is now installed into C:\Liberty\wlp
6. Go into the C:\Liberty\wlp\bin directory ('CD c:\Liberty\wlp\bin').
7. Create a new default server profile, by running the following command 'server create'
B. Install Code Rally WAR
8. Copy the WAR file into the dropins directory, by running the following command:
- copy "<location>/CodeRallyServer.war" "c:\Liberty\wlp\usr\servers\defaultServer\dropins"
- Note: If the 'c:\Liberty\wlp\usr\servers\defaultServer' directory does not exist, make sure you ran step 7 above.
- Note: The quotation marks are required on Windows, as the path contains spaces.
C. Add the WebSocket feature to Liberty's server.xml (that is, it's configuration file), and set the listen host
9. In a text editor, open the Liberty server configuration file from C:\Liberty\wlp\usr\servers\defaultServer\server.xml.
- NOTE: You cannot use Notepad for this, as the server.xml file uses Unix file configuration. To edit the file I'd recommend WordPad (not the best choice), or any of these Windows text-editors: Sublime, Kate, Jedit, Notepad2, UltraEdit, etc.
- You can also add the Liberty server under the 'Servers' view in the Code Rally client, by right clicking > New > Server > Liberty Profile (either one) and selecting the installation directory. This lets you use the built in Liberty config tools in WDT/Code Rally Client.
10. Add the following feature to the feature list '<feature>websocket-1.0</feature>', in the server.xml configuration file:
<!-- Enable features -->
... other features ...
<feature>websocket-1.1</feature> <==== Add this line
... other features ...
11. Add the following 'host' attribute to 'httpEndpoint' element:
<httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint" host="(put your machine host name here)"/>
- host should be the host name of the machine you wish to listen on. If you set '127.0.0.1' or 'localhost', external machines will not be able to connect. If you set the host to be "*" then anyone with your machines' IP address can race on it.
- Ensure that security/network/firewall policy allows listening on httpPort 9080 on your machine. If not, change this to port 80.
D. Starting the Server
12. Go into the C:\Liberty\wlp\bin directory ('CD C:\Liberty\wlp\bin') and run the start command, 'server start'
13. To stop the server, use 'server stop'. If you want the server to run in the same window as the Command Prompt -- which allows you to see the Liberty console -- use 'server run' (CTRL-Break to stop the server).
14. For troubleshooting, see the log files in C:\Liberty\wlp\usr\servers\defaultServer\logs