From 15631643014f1f540b9ac33adf91121222be1bff Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Wed, 2 Oct 2013 15:20:08 +0900 Subject: [PATCH 01/25] Update Start for Play 2.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Location of the Unix script that starts a Play application has changed in 2.2. Prior, to 2.2 the Unix script was named start and it resided in the root level folder of the distribution. With 2.2 the start script is named as per the project’s name and it resides in the distribution’s bin folder. --- .openshift/action_hooks/start | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.openshift/action_hooks/start b/.openshift/action_hooks/start index 4b6fb7a..5cf4e3d 100755 --- a/.openshift/action_hooks/start +++ b/.openshift/action_hooks/start @@ -1,10 +1,8 @@ #!/bin/bash # The logic to start up your application should be put in this # script. The application will work only if it binds to -# $OPENSHIFT_INTERNAL_IP:8080 +# $OPENSHIFT_DIY_IP:8080 - -# loads $PLAY_PARAMS . ${OPENSHIFT_REPO_DIR}.openshift/action_hooks/load_config if [[ ! $? -eq 0 ]]; then @@ -13,12 +11,12 @@ fi LOG_FILE="${OPENSHIFT_DIY_LOG_DIR}play.log" -chmod +x ${OPENSHIFT_REPO_DIR}target/start +chmod +x ${OPENSHIFT_REPO_DIR}diy/target/universal/stage/bin/${OPENSHIFT_APP_NAME} -APP_COMMAND="${OPENSHIFT_REPO_DIR}target/start $PLAY_PARAMS "\ +APP_COMMAND="${OPENSHIFT_REPO_DIR}diy/target/universal/stage/bin/${OPENSHIFT_APP_NAME} $PLAY_PARAMS "\ "-Dhttp.port=${OPENSHIFT_DIY_PORT} "\ "-Dhttp.address=${OPENSHIFT_DIY_IP} "\ "-Dconfig.resource=openshift.conf" echo $APP_COMMAND &>> $LOG_FILE -nohup bash -c "${APP_COMMAND} &>> ${LOG_FILE} 2>&1" &> /dev/null & \ No newline at end of file +nohup bash -c "${APP_COMMAND} &>> ${LOG_FILE} 2>&1" &> /dev/null & From 0ec51f55cda978746eaa2603c60651f775e7581a Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Wed, 2 Oct 2013 16:25:39 +0900 Subject: [PATCH 02/25] Update README.md Updating for Play 2.2 --- README.md | 56 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index cf2c617..d2f44ee 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Play framework 2 application on OpenShift Express +Play framework 2.2 application on OpenShift Express ============================ This git repository will help you get up and running quickly with a Play framework 2 application @@ -7,13 +7,13 @@ on OpenShift Express taking advantage of the do-it-yourself cartridge. Running on OpenShift -------------------- -Create a new Play framework 2 application +Create a new Play framework 2.2 or greater application play new play2demo cd play2demo - git init + Register at http://openshift.redhat.com/, and then create a diy (do-it-yourself) application: rhc app create play2demo -t diy-0.1 --no-git -l yourlogin @@ -22,32 +22,32 @@ You will see something like the following: ```bash -Creating application 'play2demo' -========================= - - Namespace: yourdomain - Gear Size: default - Scaling: no - Cartridge: diy-0.1 - -Your application's domain name is being propagated worldwide (this might take a minute)... -play2demo @ http://play2demo-yourdomain.rhcloud.com/ -================================= - Application Info - ================ - Gear Size = small - Git URL = ssh://your_uuid@play2demo-yourdomain.rhcloud.com/~/git/play2demo.git/ - SSH URL = ssh://your_uuid@play2demo-yourdomain.rhcloud.com - UUID = your_uuid - Created = 6:06 PM - Cartridges - ========== - diy-0.1 +Application Options +------------------- + Namespace: yourdomain + Cartridges: diy-0.1 + Gear Size: default + Scaling: no + +Creating application 'play2demo' ... done + +Waiting for your DNS name to be available ... done + +play2demo @ http://play2demo-yourdomain.rhcloud.com/ (uuid: your_uuid) +------------------------------------------------------------------------------- + Created: 3:28 PM + Gears: 1 (defaults to small) + Git URL: ssh://your_uuid@play2demo-yourdomain.rhcloud.com/~/git/play2demo.git/ + SSH: your_uuid@play2demo-yourdomain.rhcloud.com + + diy-0.1 (Do-It-Yourself 0.1) + ---------------------------- + Gears: 1 small RESULT: Application play2demo was created. -Disclaimer: This is an experimental cartridge that provides a way to try unsupported languages, -frameworks, and middleware on Openshift. +Disclaimer: This is an experimental cartridge that provides a way to try unsupported languages, frameworks, and middleware on +Openshift. ``` Copy and paste the git url to add it as a remote repo (replace the uuid part with your own!) @@ -59,7 +59,7 @@ Copy and paste the git url to add it as a remote repo (replace the uuid part wit And then add this repository as a remote repo named quickstart: - git remote add quickstart -m master git://github.com/opensas/play2-openshift-quickstart.git + git remote add quickstart -m master git://github.com/JamesSullivan/play2.2-openshift-quickstart.git git pull -s recursive -X theirs quickstart master Then use the stage task to prepare your deployment @@ -301,6 +301,8 @@ Play will then run your app in production mode. The server will listen to ${OPEN Acknowledgments ---------------------------- +Minor updates to work by Opensas. + I couldn't have developed this quickstart without the help of [marekjelen](https://github.com/marekjelen) who answered [my questions on stackoverflow](http://stackoverflow.com/questions/9446275/best-approach-to-integrate-netty-with-openshift) and who also shared his [JRuby quickstart repo](https://github.com/marekjelen/openshift-jruby#readme). (I know, open source rocks!) It was also of great help Grant Shipley's [article on building a quickstart for openshift](https://www.redhat.com/openshift/community/blogs/how-to-create-an-openshift-github-quick-start-project). From ebfd199f2625c757802a361219a97ff1a4960037 Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Wed, 2 Oct 2013 16:36:11 +0900 Subject: [PATCH 03/25] Update start corrected path to app name --- .openshift/action_hooks/start | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.openshift/action_hooks/start b/.openshift/action_hooks/start index 5cf4e3d..0f96637 100755 --- a/.openshift/action_hooks/start +++ b/.openshift/action_hooks/start @@ -11,9 +11,9 @@ fi LOG_FILE="${OPENSHIFT_DIY_LOG_DIR}play.log" -chmod +x ${OPENSHIFT_REPO_DIR}diy/target/universal/stage/bin/${OPENSHIFT_APP_NAME} +chmod +x ${OPENSHIFT_REPO_DIR}/target/universal/stage/bin/${OPENSHIFT_APP_NAME} -APP_COMMAND="${OPENSHIFT_REPO_DIR}diy/target/universal/stage/bin/${OPENSHIFT_APP_NAME} $PLAY_PARAMS "\ +APP_COMMAND="${OPENSHIFT_REPO_DIR}/target/universal/stage/bin/${OPENSHIFT_APP_NAME} $PLAY_PARAMS "\ "-Dhttp.port=${OPENSHIFT_DIY_PORT} "\ "-Dhttp.address=${OPENSHIFT_DIY_IP} "\ "-Dconfig.resource=openshift.conf" From 82a54dcd18db12c4b1835b974f0ded1fa01e11c1 Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Wed, 2 Oct 2013 21:34:11 +0900 Subject: [PATCH 04/25] Change to handle versions Play 2 earlier than Play 2.2 --- .openshift/action_hooks/start | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.openshift/action_hooks/start b/.openshift/action_hooks/start index 0f96637..4eaac02 100755 --- a/.openshift/action_hooks/start +++ b/.openshift/action_hooks/start @@ -10,10 +10,19 @@ if [[ ! $? -eq 0 ]]; then fi LOG_FILE="${OPENSHIFT_DIY_LOG_DIR}play.log" +APP_PATH="${OPENSHIFT_REPO_DIR}/target/universal/stage/bin/${OPENSHIFT_APP_NAME}" + +if [ -f "${OPENSHIFT_REPO_DIR}target/start" ]; +then + APP_PATH="${OPENSHIFT_REPO_DIR}target/start" + echo "Play 2.1 or earlier version" +else + echo "Play 2.2 or later version" +fi chmod +x ${OPENSHIFT_REPO_DIR}/target/universal/stage/bin/${OPENSHIFT_APP_NAME} -APP_COMMAND="${OPENSHIFT_REPO_DIR}/target/universal/stage/bin/${OPENSHIFT_APP_NAME} $PLAY_PARAMS "\ +APP_COMMAND="${APP_PATH} $PLAY_PARAMS "\ "-Dhttp.port=${OPENSHIFT_DIY_PORT} "\ "-Dhttp.address=${OPENSHIFT_DIY_IP} "\ "-Dconfig.resource=openshift.conf" From c4f1df355bd2e5da48b2fa8feddc20a2010c7479 Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Wed, 2 Oct 2013 21:38:50 +0900 Subject: [PATCH 05/25] Updated readme to make clear works with Play versions 2.0 through 2.2 --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d2f44ee..7b22f86 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Play framework 2.2 application on OpenShift Express +Play framework 2 application on OpenShift Express ============================ This git repository will help you get up and running quickly with a Play framework 2 application @@ -7,7 +7,7 @@ on OpenShift Express taking advantage of the do-it-yourself cartridge. Running on OpenShift -------------------- -Create a new Play framework 2.2 or greater application +Create a new Play framework 2.0, 2.1 or 2.2 application play new play2demo cd play2demo @@ -301,8 +301,6 @@ Play will then run your app in production mode. The server will listen to ${OPEN Acknowledgments ---------------------------- -Minor updates to work by Opensas. - I couldn't have developed this quickstart without the help of [marekjelen](https://github.com/marekjelen) who answered [my questions on stackoverflow](http://stackoverflow.com/questions/9446275/best-approach-to-integrate-netty-with-openshift) and who also shared his [JRuby quickstart repo](https://github.com/marekjelen/openshift-jruby#readme). (I know, open source rocks!) It was also of great help Grant Shipley's [article on building a quickstart for openshift](https://www.redhat.com/openshift/community/blogs/how-to-create-an-openshift-github-quick-start-project). From 49749edd497094f62e7a9b0eed730f2a55ce725d Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Thu, 3 Oct 2013 09:46:26 +0900 Subject: [PATCH 06/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7b22f86..9ccff56 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Copy and paste the git url to add it as a remote repo (replace the uuid part wit And then add this repository as a remote repo named quickstart: - git remote add quickstart -m master git://github.com/JamesSullivan/play2.2-openshift-quickstart.git + git remote add quickstart -m master git://github.com/JamesSullivan/play2-openshift-quickstart.git git pull -s recursive -X theirs quickstart master Then use the stage task to prepare your deployment From b229ab661e2586b4f9b97080936fc59a30661580 Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Thu, 3 Oct 2013 09:57:11 +0900 Subject: [PATCH 07/25] Update start --- .openshift/action_hooks/start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.openshift/action_hooks/start b/.openshift/action_hooks/start index 4eaac02..7ab22f0 100755 --- a/.openshift/action_hooks/start +++ b/.openshift/action_hooks/start @@ -20,7 +20,7 @@ else echo "Play 2.2 or later version" fi -chmod +x ${OPENSHIFT_REPO_DIR}/target/universal/stage/bin/${OPENSHIFT_APP_NAME} +chmod +x ${APP_PATH} APP_COMMAND="${APP_PATH} $PLAY_PARAMS "\ "-Dhttp.port=${OPENSHIFT_DIY_PORT} "\ From f4701243869f227e097cba1f83a375e8aba4f326 Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Thu, 3 Oct 2013 11:05:50 +0900 Subject: [PATCH 08/25] Update start --- .openshift/action_hooks/start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.openshift/action_hooks/start b/.openshift/action_hooks/start index 7ab22f0..6e7902d 100755 --- a/.openshift/action_hooks/start +++ b/.openshift/action_hooks/start @@ -10,7 +10,7 @@ if [[ ! $? -eq 0 ]]; then fi LOG_FILE="${OPENSHIFT_DIY_LOG_DIR}play.log" -APP_PATH="${OPENSHIFT_REPO_DIR}/target/universal/stage/bin/${OPENSHIFT_APP_NAME}" +APP_PATH="${OPENSHIFT_REPO_DIR}target/universal/stage/bin/${OPENSHIFT_APP_NAME}" if [ -f "${OPENSHIFT_REPO_DIR}target/start" ]; then From 9dca03926b158759594f8941c2b9336e5cd479d3 Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Thu, 3 Oct 2013 11:07:01 +0900 Subject: [PATCH 09/25] Update start --- .openshift/action_hooks/start | 1 + 1 file changed, 1 insertion(+) diff --git a/.openshift/action_hooks/start b/.openshift/action_hooks/start index 6e7902d..6e10e00 100755 --- a/.openshift/action_hooks/start +++ b/.openshift/action_hooks/start @@ -19,6 +19,7 @@ then else echo "Play 2.2 or later version" fi +echo APP_PATH chmod +x ${APP_PATH} From bb0e9d3f1a5e5cc4a50d839949f9103899f043af Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Thu, 3 Oct 2013 12:11:58 +0900 Subject: [PATCH 10/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ccff56..3a32caa 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Create a new Play framework 2.0, 2.1 or 2.2 application Register at http://openshift.redhat.com/, and then create a diy (do-it-yourself) application: - rhc app create play2demo -t diy-0.1 --no-git -l yourlogin + rhc app-create play2demo diy-0.1 --no-git -l yourlogin You will see something like the following: From 92f5456f87a5997a52f25970effe95258f30bd1f Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Thu, 3 Oct 2013 12:20:50 +0900 Subject: [PATCH 11/25] Update start --- .openshift/action_hooks/start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.openshift/action_hooks/start b/.openshift/action_hooks/start index 6e10e00..e7d5783 100755 --- a/.openshift/action_hooks/start +++ b/.openshift/action_hooks/start @@ -19,7 +19,7 @@ then else echo "Play 2.2 or later version" fi -echo APP_PATH +echo "${APP_PATH} $PLAY_PARAMS " chmod +x ${APP_PATH} From 8676d4a696e7065d4e903642dbe58d5ec70edc34 Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Thu, 3 Oct 2013 12:24:48 +0900 Subject: [PATCH 12/25] Update start --- .openshift/action_hooks/start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.openshift/action_hooks/start b/.openshift/action_hooks/start index e7d5783..8db083a 100755 --- a/.openshift/action_hooks/start +++ b/.openshift/action_hooks/start @@ -19,7 +19,6 @@ then else echo "Play 2.2 or later version" fi -echo "${APP_PATH} $PLAY_PARAMS " chmod +x ${APP_PATH} @@ -27,6 +26,7 @@ APP_COMMAND="${APP_PATH} $PLAY_PARAMS "\ "-Dhttp.port=${OPENSHIFT_DIY_PORT} "\ "-Dhttp.address=${OPENSHIFT_DIY_IP} "\ "-Dconfig.resource=openshift.conf" +echo "${APP_COMMAND}" echo $APP_COMMAND &>> $LOG_FILE nohup bash -c "${APP_COMMAND} &>> ${LOG_FILE} 2>&1" &> /dev/null & From 54c9e94e2abebc1f91ab8324d5491c1971a61d73 Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Thu, 3 Oct 2013 12:43:42 +0900 Subject: [PATCH 13/25] Update start --- .openshift/action_hooks/start | 1 + 1 file changed, 1 insertion(+) diff --git a/.openshift/action_hooks/start b/.openshift/action_hooks/start index 8db083a..76152e1 100755 --- a/.openshift/action_hooks/start +++ b/.openshift/action_hooks/start @@ -3,6 +3,7 @@ # script. The application will work only if it binds to # $OPENSHIFT_DIY_IP:8080 +# loads $PLAY_PARAMS . ${OPENSHIFT_REPO_DIR}.openshift/action_hooks/load_config if [[ ! $? -eq 0 ]]; then From 39fc8cd2057dbb650a2f07472548ec68b8dbb216 Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Thu, 3 Oct 2013 12:46:16 +0900 Subject: [PATCH 14/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3a32caa..5a42ef9 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Copy and paste the git url to add it as a remote repo (replace the uuid part wit And then add this repository as a remote repo named quickstart: - git remote add quickstart -m master git://github.com/JamesSullivan/play2-openshift-quickstart.git + git remote add quickstart -m master git://github.com/opensas/play2-openshift-quickstart.git git pull -s recursive -X theirs quickstart master Then use the stage task to prepare your deployment From 7400ca28990d20b27a62d80689fc04f7a634d2ef Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Thu, 3 Oct 2013 13:01:54 +0900 Subject: [PATCH 15/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a42ef9..3a32caa 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Copy and paste the git url to add it as a remote repo (replace the uuid part wit And then add this repository as a remote repo named quickstart: - git remote add quickstart -m master git://github.com/opensas/play2-openshift-quickstart.git + git remote add quickstart -m master git://github.com/JamesSullivan/play2-openshift-quickstart.git git pull -s recursive -X theirs quickstart master Then use the stage task to prepare your deployment From 878aa86df70d7c8b1fdef269873bf6b844f49582 Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Wed, 27 Nov 2013 17:54:45 +0900 Subject: [PATCH 16/25] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3a32caa..7f9c8bd 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ Play framework 2 application on OpenShift Express ============================ -This git repository will help you get up and running quickly with a Play framework 2 application +This a copied and Updated version of https://github.com/opensas/play2-openshift-quickstart +(waiting on a pull request) + +This git repository will help you get up and running quickly with a Play framework 2 application on OpenShift Express taking advantage of the do-it-yourself cartridge. Running on OpenShift From c5a7264b0cee5bb5f2fa04283ffc93f628088803 Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Sun, 8 Dec 2013 18:58:53 +0900 Subject: [PATCH 17/25] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 7f9c8bd..a80e584 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ Play framework 2 application on OpenShift Express ============================ -This a copied and Updated version of https://github.com/opensas/play2-openshift-quickstart -(waiting on a pull request) +This a copied and Updated version of https://github.com/opensas/play2-openshift-quickstart that supports Play Framework 2.2 (which the original does not) as well as earlier versions. This git repository will help you get up and running quickly with a Play framework 2 application on OpenShift Express taking advantage of the do-it-yourself cartridge. From 3b9ef83e5ab7ae30e700ddc56111adec71f848e7 Mon Sep 17 00:00:00 2001 From: jschaul Date: Tue, 10 Dec 2013 13:52:06 +0100 Subject: [PATCH 18/25] Update stop: only kill the play process, not any other java processes. I had the issue of git push failing due to an error in the stop script: it attempts to pkill java, however, play is not the only java process active, there is also activemq. The app has no permission to kill the activemq process so the stop script fails. These changes rectify this. Tested with a local Openshift Origin application. --- .openshift/action_hooks/stop | 76 ++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/.openshift/action_hooks/stop b/.openshift/action_hooks/stop index 2e437ca..956ba07 100755 --- a/.openshift/action_hooks/stop +++ b/.openshift/action_hooks/stop @@ -1,32 +1,34 @@ #!/bin/bash # The logic to stop your application should be put in this script. -# debug +# debug # set -x LOG_FILE="${OPENSHIFT_DIY_LOG_DIR}play.log" +PLAY_PROCESS="[j]ava .*com.typesafe.play.*" + function kill_app { - COMMAND="$1" - # try 5 times to kill it - for c in `seq 1 5`; do - echo "Trying to kill proccess, attempt number $c" >> $LOG_FILE - echo "$COMMAND" >> $LOG_FILE - bash -c "$COMMAND &>> $LOG_FILE 2>&1" &> /dev/null - sleep $c - #killed it - if [[ -z `ps -A | grep ' java$'` ]]; then - if [[ -f "RUNNING_PID" ]]; then - rm RUNNING_PID - fi - popd > /dev/null - exit 0 - fi - done + COMMAND="$1" + # try 5 times to kill it + for c in `seq 1 5`; do + echo "Trying to kill proccess, attempt number $c" >> $LOG_FILE + echo "$COMMAND" >> $LOG_FILE + bash -c "$COMMAND &>> $LOG_FILE 2>&1" &> /dev/null + sleep $c + #killed it + if [[ -z `ps aux | grep "$PLAY_PROCESS"` ]]; then + if [[ -f "RUNNING_PID" ]]; then + rm RUNNING_PID + fi + popd > /dev/null + exit 0 + fi + done } if [[ ! $? -eq 0 ]]; then - exit $? + exit $? fi pushd "$OPENSHIFT_REPO_DIR" > /dev/null @@ -34,31 +36,31 @@ pushd "$OPENSHIFT_REPO_DIR" > /dev/null #kill play if it was running if [[ -f "RUNNING_PID" ]]; then - pid=`cat RUNNING_PID` - echo "Stopping play application" >> $LOG_FILE + pid=`cat RUNNING_PID` + echo "Stopping play application" >> $LOG_FILE - if [[ -n $pid ]]; then - #try to kill it nicely - kill_app "kill -SIGTERM $pid" - #try to kill it harshly - kill_app "kill -SIGKILL $pid" - fi + if [[ -n $pid ]]; then + #try to kill it nicely + kill_app "kill -SIGTERM $pid" + #try to kill it harshly + kill_app "kill -SIGKILL $pid" + fi fi -#it survived, try to kill java -if [[ -n `ps -A | grep java` ]]; then - echo "Stopping java proccess" >> $LOG_FILE - #try to kill it nicely - kill_app "pkill -SIGTERM java" - #try to kill it harshly - kill_app "pkill -SIGKILL java" +#it survived, try to kill anything with play in it +if [[ -z `ps aux | grep "$PLAY_PROCESS"` ]]; then + echo "Stopping java play proccess" >> $LOG_FILE + #try to kill it nicely + kill_app "ps aux | grep \"$PLAY_PROCESS\" | awk '{print $2}' | xargs kill -SIGTERM" + #try to kill it harshly + kill_app "ps aux | grep \"$PLAY_PROCESS\" | awk '{print $2}' | xargs kill -SIGKILL" fi #couldn't kill it -if [[ -n `ps -A | grep java` ]]; then - echo "Error: could not stop play application, error executing 'pkill java'" >> $LOG_FILE - popd - exit 1 +if [[ -z `ps aux | grep "$PLAY_PROCESS"` ]]; then + echo "Error: could not stop play application, error executing 'ps aux | grep \"$PLAY_PROCESS\" | awk '{print $2}' | xargs kill -SIGKILL'" >> $LOG_FILE + popd + exit 1 fi popd > /dev/null From 6573c307934a242fd4ec20082c2944204ea0536e Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Wed, 14 May 2014 18:55:17 +0900 Subject: [PATCH 19/25] Update stop back to killing all java processes to stop as play is not being detected from cut off ps aux text. --- .openshift/action_hooks/stop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.openshift/action_hooks/stop b/.openshift/action_hooks/stop index 956ba07..e6d28b7 100755 --- a/.openshift/action_hooks/stop +++ b/.openshift/action_hooks/stop @@ -6,7 +6,7 @@ LOG_FILE="${OPENSHIFT_DIY_LOG_DIR}play.log" -PLAY_PROCESS="[j]ava .*com.typesafe.play.*" +PLAY_PROCESS="java *" function kill_app { COMMAND="$1" From d05d6cdd3351662b3aef34f1d556cd3aa60f2e55 Mon Sep 17 00:00:00 2001 From: Michal Lachowski Date: Thu, 22 May 2014 14:30:48 +0200 Subject: [PATCH 20/25] Update README.MD In section 'step by step example' link to git repo is in older version (without play 2.2 support). Should be git://github.com/JamesSullivan/play2-openshift-quickstart.git --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a80e584..371d332 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,7 @@ Copy and paste the git url to add it as a remote repo (replace the uuid part wit That's it, you have just cloned your openshift repo, now we will add the quickstart repo: - git remote add quickstart -m master git://github.com/opensas/play2-openshift-quickstart.git + git remote add quickstart -m master git://github.com/JamesSullivan/play2-openshift-quickstart.git git pull -s recursive -X theirs quickstart master Then run the stage task, add your changes to git's index, commit and push the repo upstream (you can also just run the *openshift_deploy* script): From f62fab58f7bc78b0ebca14a488b81b794c3af0da Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Tue, 24 Jun 2014 10:58:15 +0900 Subject: [PATCH 21/25] Notes for Play 2.3 Noted that for Play 2.3 the play command has been replaced by the activator command and that must be changed in the openshift_deploy script. --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 371d332..97dd394 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Play framework 2 application on OpenShift Express ============================ -This a copied and Updated version of https://github.com/opensas/play2-openshift-quickstart that supports Play Framework 2.2 (which the original does not) as well as earlier versions. +This a copied and Updated version of https://github.com/opensas/play2-openshift-quickstart that supports Play Framework 2.2 and 2.3 (which the original does not) as well as earlier versions. This git repository will help you get up and running quickly with a Play framework 2 application on OpenShift Express taking advantage of the do-it-yourself cartridge. @@ -9,9 +9,20 @@ on OpenShift Express taking advantage of the do-it-yourself cartridge. Running on OpenShift -------------------- -Create a new Play framework 2.0, 2.1 or 2.2 application +NOTE FOR PLAY 2.3 USERS: With the move to Play 2.3 the 'play' command has been replaced by the 'activator' command so for the remainder of this quickstart if you are using Play 2.3 simply replace all instances of the play command with activator. If you use the 'openshift_deploy' helper script you will also need to edit that and replace all instances of 'play' with 'activator' and then save it. + +Create a new Play framework 2.0, 2.1, 2.2 or 2.3 application + +For Play 2.0, 2.1 or 2.2 use play new play2demo + +For Play 2.3 use + + activator new play2demo + +And then + cd play2demo git init @@ -66,8 +77,14 @@ And then add this repository as a remote repo named quickstart: Then use the stage task to prepare your deployment +For Play 2.0, 2.1 or 2.2 use + play clean compile stage +For Play 2.3 use + + activator clean compile stage + And add your changes to git's index, commit and push the repo upstream: git add . From e6fcc1dcd2abba1bfac610bf1d3231fb4fc6e4f1 Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Tue, 24 Jun 2014 18:37:01 +0900 Subject: [PATCH 22/25] Link so that public folder is accessible --- .openshift/action_hooks/build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.openshift/action_hooks/build b/.openshift/action_hooks/build index c0df17b..2050cce 100755 --- a/.openshift/action_hooks/build +++ b/.openshift/action_hooks/build @@ -2,4 +2,7 @@ # This is a simple build script and will be executed on your CI system if # available. Otherwise it will execute while your application is stopped # before the deploy step. This script gets executed directly, so it -# could be python, php, ruby, etc. \ No newline at end of file +# could be python, php, ruby, etc. +echo "ln -s ${OPENSHIFT_REPO_DIR}public ${STAGING}public" +STAGING="${OPENSHIFT_REPO_DIR}target/universal/stage/" +ln -s ${OPENSHIFT_REPO_DIR}public ${STAGING}public From 20e320ba8472bd1590dadabd71d895aface5f72e Mon Sep 17 00:00:00 2001 From: Michal Lachowski Date: Thu, 26 Jun 2014 16:57:04 +0200 Subject: [PATCH 23/25] Update stop Hi James. I had some problem with my app deployed on openshift and just did some digging. My Problem was in this stop script. During executions of this part of code: if [[ -f "RUNNING_PID" ]] ... script is looking for RUNNING_PID inside $OPENSHIFT_REPO_DIR, but there is no such file there. RUNNING_PID is being created inside $OPENSHIFT_REPO_DIR/target/universal/stage/. I tested it and it works for me. --- .openshift/action_hooks/stop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.openshift/action_hooks/stop b/.openshift/action_hooks/stop index e6d28b7..b5fdf61 100755 --- a/.openshift/action_hooks/stop +++ b/.openshift/action_hooks/stop @@ -31,7 +31,7 @@ if [[ ! $? -eq 0 ]]; then exit $? fi -pushd "$OPENSHIFT_REPO_DIR" > /dev/null +pushd "$OPENSHIFT_REPO_DIR/target/universal/stage/" > /dev/null #kill play if it was running if [[ -f "RUNNING_PID" ]]; then From 6e621488dd8b4d712e4ce20b2fb719cc40b16610 Mon Sep 17 00:00:00 2001 From: Karan Kaushik Date: Sun, 29 Jun 2014 13:42:27 -0700 Subject: [PATCH 24/25] Change openshift.conf to reflect new environment variables for mysql db --- README.md | 2 +- conf/openshift.conf | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 97dd394..d0e71fc 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ Then uncomment the following lines from your conf/openshift.conf, like this: db.default.user=${OPENSHIFT_DB_USERNAME} db.default.password=${OPENSHIFT_DB_PASSWORD} -You'll also have to include the mysql driver as a dependency. Add this line to project/Build.scala file: +You'll also have to include the mysql driver as a dependency. Add this line to your build.sbt or project/Build.scala file: val appDependencies = Seq( "mysql" % "mysql-connector-java" % "5.1.18" diff --git a/conf/openshift.conf b/conf/openshift.conf index d982df4..b6d2992 100644 --- a/conf/openshift.conf +++ b/conf/openshift.conf @@ -15,9 +15,9 @@ application.secret="d=ODZSG[_Y?mYq=]7a3eFSdlJ6gq>PP]/t]QF38lY;aLF;^t`uE>]vM9?30b # By convention, the default datasource is named `default` # # db.default.driver=com.mysql.jdbc.Driver -# db.default.url="jdbc:mysql://"${OPENSHIFT_DB_HOST}":"${OPENSHIFT_DB_PORT}/${OPENSHIFT_APP_NAME} -# db.default.user=${OPENSHIFT_DB_USERNAME} -# db.default.password=${OPENSHIFT_DB_PASSWORD} +# db.default.url="jdbc:mysql://"${OPENSHIFT_MYSQL_DB_HOST}":"${OPENSHIFT_MYSQL_DB_PORT}/${OPENSHIFT_APP_NAME} +# db.default.user=${OPENSHIFT_MYSQL_DB_USERNAME} +# db.default.password=${OPENSHIFT_MYSQL_DB_PASSWORD} # # db.default.driver=org.h2.Driver # db.default.url="jdbc:h2:mem:play" From f5f0a6c9a392c8e9cf74cbf84bd8f218174c9085 Mon Sep 17 00:00:00 2001 From: JamesSullivan Date: Fri, 5 Sep 2014 15:19:17 +0900 Subject: [PATCH 25/25] Update README.md with link to a different approach --- README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d0e71fc..45cd59d 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,7 @@ -Play framework 2 application on OpenShift Express +Play framework 2.X application on OpenShift Express ============================ -This a copied and Updated version of https://github.com/opensas/play2-openshift-quickstart that supports Play Framework 2.2 and 2.3 (which the original does not) as well as earlier versions. - -This git repository will help you get up and running quickly with a Play framework 2 application -on OpenShift Express taking advantage of the do-it-yourself cartridge. +This git repository will help you get up and running quickly with a Play Framework 2 application (including versions 2.1, 2.2 and 2.3) on OpenShift Express taking advantage of the do-it-yourself cartridge. To work within the constrained amount of memory available in the free versions of OpenShift, compilation takes place locally and is then deployed. For a different approach from that taken here see http://misto.ch/play-on-openshift/ Running on OpenShift -------------------- @@ -320,6 +317,12 @@ Play will then run your app in production mode. The server will listen to ${OPEN Acknowledgments ---------------------------- +This a copied and Updated version of https://github.com/opensas/play2-openshift-quickstart with contributions from a number of people since then. + + +Original Author Acknowledgments +---------------------------- + I couldn't have developed this quickstart without the help of [marekjelen](https://github.com/marekjelen) who answered [my questions on stackoverflow](http://stackoverflow.com/questions/9446275/best-approach-to-integrate-netty-with-openshift) and who also shared his [JRuby quickstart repo](https://github.com/marekjelen/openshift-jruby#readme). (I know, open source rocks!) It was also of great help Grant Shipley's [article on building a quickstart for openshift](https://www.redhat.com/openshift/community/blogs/how-to-create-an-openshift-github-quick-start-project).