At the time of writing this post, a WildFly cartridge is not available on OpenShift. However, it's relatively simple to get it running using the DIY cartridge.
If you don't already have an OpenShift account go to https://www.openshift.com/ and create one now.
Create a new application
First step to doing this is to create a new application on OpenShift using the DIY cartridge. This can either be done through the web console or using the rhc command line tool.
To create the application using the web interface open https://openshift.redhat.com/app/console/applications and select add application. Select the Do-It-Yourself cartridge. Insert a name for the application and click on Create Application. On the next page follow the instructions to clone the Git repository for the application.
Install WildFly
Download WildFly from http://www.wildfly.org/download/ and extract it into the directory where you cloned the applications Git repository.
To make WildFly run on OpenShift you'll need to do a few minor configuration changes. Open the wildfly-8.0.0.Alpha1/standalone/configuration/standalone.xml in your favourite text editor.
First thing to do is to set the interfaces to use loopback addresses. Search for <interfaces> and replace inet-address with loopback-address. The result should be:
<interfaces> <interface name="management"> <loopback-address value="${jboss.bind.address.management:127.0.0.1}"></loopback-address> </interface> <interface name="public"> <loopback-address value="${jboss.bind.address:127.0.0.1}"></loopback-address> </interface> <interface name="unsecure"> <loopback-address value="${jboss.bind.address.unsecure:127.0.0.1}"> </loopback-address></interface> </interfaces>
Next, if your application is using the example datasource you may want to configure this to be persisted. Search for <datasources> for the ExampleDS datasource entry replace the value of the connection-url with:
jdbc:h2:mem:test;DB_CLOSE_DELAY=-1/jdbc:h2:${jboss.server.data.dir}/test;DB_CLOSE_DELAY=-1
Finally, the timeout for a deployment is set to 60 seconds by default, and if you're using the free gear this may cause deployments to fail. To increase the deployment timeout search for deployment-scanner and set the deployment-timeout attribute. For 300 seconds timeout it would be:
<deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" deployment-timeout="300"/>
Edit start and stop scripts
Open .openshift/action_hooks/start in a text editor and replace the contents with:
#!/bin/bash ln -s $OPENSHIFT_DATA_DIR $OPENSHIFT_REPO_DIR/wildfly-8.0.0.Alpha1/standalone/data cd $OPENSHIFT_REPO_DIR/wildfly-8.0.0.Alpha1 nohup bin/standalone.sh -b $OPENSHIFT_DIY_IP -bmanagement=$OPENSHIFT_DIY_IP > $OPENSHIFT_DIY_DIR/logs/server.log 2>&1 &
Then open .openshift/action_hooks/stop and replace the contents with:
#!/bin/bash jps | grep jboss-modules.jar | cut -d ' ' -f 1 | xargs kill exit 0
Push changes to Openshift
Now it's time to commit and push the changes to OpenShift. Run:
git commit -m "Added WildFly" -a git pushOnce the data has been sent to OpenShift the application will be restarted and you should have a running instance of WildFly on OpenShift. To deploy your applications to the WildFly instance simply copy them to standalone/deployments and use git commit/push to upload to OpenShift.
No comments:
Post a Comment