Works with Play 2.5 and Activator : http://www.playframework.com/
Here the gear command implemented:
Command | Description |
---|---|
gear start |
Start the application, this command has a different behaviour if PLAY2_APPLICATION_PATH point to: 1. a distribution zip file (see Deploy application from distribution file); 2. build from source code (see Deploy application from source code code). |
gear stop |
Stop the application. |
gear restart |
Stop and then start the application. |
gear status |
Get current application status. |
gear tidy |
Remove files from $OPENSHIFT_TMP_DIR. |
gear build |
Build the application from source , if PLAY2_APPLICATION_PATH doesn't point to a zip file. |
Example:
$ gear status
Cart to get the status for?
1. play2-2.5.0
? 1
ATTR: quota_blocks=1048576
ATTR: quota_files=80000
CLIENT_RESULT: Application is running
Environment variables could be set in ${OPENSHIFT_DATA_DIR}/.profile file. In this file it is defined the following variables:
- PLAY2_APPLICATION_PATH : point to the directory where application is stored. It is possible to set to a specific distribution file in order to deploy;
- JAVA_OPTS : Java options. The default is to use initial and maximum Java heap size to 512MB
- SBT_OPTS : SBT options. The default is to use initial and maximum Java heap size to 512MB
In order to deploy an application from distribution file (zip dist file) follow these steps:
- Create openshift gear from cartridge play2
- Clone openshift gear repository locally:
git clone ssh://Here-repository-url
- Build locally zip file
- Connect via ssh to openshift gear
- Update PLAY2_APPLICATION_PATH variable in ~/.profile:
Note: replace "my-application-1.0-SNAPSHOT.zip" with your dist zip file.
export PLAY2_APPLICATION_PATH=/var/lib/openshift/56f861dd7628e1713600003c/app-root/runtime/repo/my-application-1.0-SNAPSHOT.zip
- Copy local zip file inside openshift git repository
- Publish your dist to openshift gear:
$ git add .
$ git commit -m "Here insert a useful comment"
$ git push origin master
Your new application is now published 😃
ATTENTION: Publish a dist file is very smart solution but this solution could be fill your openshift gear disk because git repository maintains an history of all dist file versions.
In order to deploy an application from source follow these steps:
- Create openshift gear from cartridge play2
- Clone openshift gear repository locally:
git clone ssh://Here-repository-url
- Open/import project with your favourite development IDE
- Test & develop locally
- After development use git to publish your new version to openshift gear:
$ git add .
$ git commit -m "Here insert a useful comment"
$ git push origin master
Your new application is now published 😃
Note: it takes a while build & publishing a new version.
Note^2: the first build process it takes a while, up to ~15 minutes because activator program download all dependencies.
Have a look at http://misto.ch/play-on-openshift/
at the moment you need to use http://cartreflect-claytondev.rhcloud.com/reflect?github=tyrcho/openshift-cartridge-play2&commit=play-2.5.0
.
- Go to https://openshift.redhat.com/app/console/applications
- Click on "Add Application…"
- Go to the bottom page and in Code Anything "URL to a cartridge definition" insert:
http://cartreflect-claytondev.rhcloud.com/reflect?github=tyrcho/openshift-cartridge-play2&commit=play-2.5.0
- Click on "Next"
- Define an url for the Application Name
- Go to the bottom page and click the button "Create Application"
- Wait ~15 minutes for the first build. It takes a while because it downloads activator and its dependecies
- Connect via ssh
- Wait until the application is stopped (via 'gear status')
- Execute 'gear build'
- Execute 'gear start'
rhc app create myappForPlay http://cartreflect-claytondev.rhcloud.com/reflect?github=tyrcho/openshift-cartridge-play2&commit=play-2.5.0
You might need to increase the timeout to let it the time to download the activator and build the application the first time.
You need to have installed Play on your development workstation.
Simply launch activator run
from your invite, and browse to http://localhost:9000/ to see the welcome page.