Visualizzazione post con etichetta openshift. Mostra tutti i post
Visualizzazione post con etichetta openshift. Mostra tutti i post

martedì 26 agosto 2014

How to hot deploy a RedHat Openshift application

Some time when you make a change to your application (in my case is a rails application) you would like to deploy the code change to your running app without restarting the cartridge on Openshift.

By default every time you perform a git push to your Openshift application, the framework execute the entire stop, build, deploy and restart activities.
This might take quite some time and your online application will not be available for few minutes.

However if you want, you can instruct Openshift to Hot Deploy your application, which means git push your code changes without restarting the application.

This will definitely reduce the downtime of your application (in most of the cases only the web server will be restarted and not the entire application cartridge like Ruby or PHP).

Enabling Hot Deploy is easy.
Add an empty hot_deploy file in the .openshift/markers directory.
Deploy this change and Openshift will understand that it should not restart the entire application when you git push your code changes


# touch .openshift/markers/hot_deploy
# git add .
# git commit -m "implementing hot deploy"
# git push


If everything is correct, next time you will push code changes to your Openshift apps, you should see something similar

remote: Not stopping cartridge ruby because hot deploy is enabled

Now your code change will be online in a quite short amount of time and especially with a very limited app downtime.

martedì 15 luglio 2014

rails console and dbconsole on OpenShift

in my rails development environment I can start the console or the DB console by issuing the well know commands:


rails c(onsole)
rails dbconsole

In order to achieve the same result in production environment on OpenShift issue the following:

cd $OPENSHIFT_REPO_DIR

RAILS_ENV=production bundle excec rails c(onsole)

RAILS_ENV=production bundle excec rails dbconsole

lunedì 14 luglio 2014

How to force HTTPS on Openshift for Rails applications

RedHat OpenShift provides the possibility to enable HTTPS for your Rails application.

By default your Rails application will be available on

http://appname-domain.rhcloud.com

and

https://appname-domain.rhcloud.com

In my applications I want every request to be handled by HTTPS. In order to achieve that add to your public directory a .htaccess file with the below content


RewriteEngine on


RewriteCond %{HTTP:X-Forwarded-Proto} !https

RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]


For additional information for non-Apache based applications check OpenShift article out