1

I am using django-haystack and whoosh search engine in my django app. Everything is working alright, except when I git push new version to my OpenShift server, search stops working. It simply does not return any results. If I run ./manage.py update_index it starts working.
I have whoosh_index/ in my .gitignore file. I checked by git ls-files and whoosh_index folder is not there. So my localhost files should not be overwriting any whoosh_index files.
Currently I use post_deploy script:

echo "Executing 'python ${OPENSHIFT_REPO_DIR}wsgi/app/manage.py update_index'"
python "$OPENSHIFT_REPO_DIR"wsgi/app/manage.py update_index

But is there another way so that I do not have to update_index everytime I push new version of my app? What am I missing?

Lucas03
  • 2,267
  • 2
  • 32
  • 60
  • You update some other python files like index schema, analyzers ..? – Assem Jan 13 '16 at 18:54
  • no, even if I add only extra space in my codes(templates, ...) and push it, index will be broken. – Lucas03 Jan 13 '16 at 18:56
  • If the index is broken so something is changed, be sure what you push. can you show us what you got with `git show HEAD` or any breaking commit? – Assem Jan 13 '16 at 19:02
  • there are just my last edits. Nothing else. May be problem is with OpenShift - (when I commit new changes, OpenShift creates new gear, rsync all data to that and adds new data from latest commit) – Lucas03 Jan 13 '16 at 19:31
  • so I think that's it, taking the commit as a trigger to run some routines – Assem Jan 13 '16 at 19:36

1 Answers1

0

From Modifying Applications

All OpenShift applications are built around a Git source control workflow - you code locally, then push your changes to the server. The server then runs a number of hooks to build and configure your application, and finally restarts your application. Optionally, applications can elect to be built using Jenkins, or run using hot deployment which speeds up the deployment of code to OpenShift.

There are 5 phases for the changes done:

  • Pre-Receive
  • Pre-Build
  • Build
  • Deploy
  • Post-Deploy

You can add the index update operation to the build phase by adding it to the file:

.openshift/action_hooks/build

You can disable the whole operation of modifying of open shift by require the hot deploy mode:

$ touch .openshift/markers/hot_deploy

With hot deployment the changes to application code are applied without restarting the application cartridge, resulting in increased deployment speed and minimized application downtime.

Assem
  • 11,574
  • 5
  • 59
  • 97
  • at the moment I am using jenkins and hot deploy(I should have mentioned that, but I thought it had nothing to do with OpenShift). Only difference is that I am updating index in post_deploy. However I would like to avoid updating index, since it takes so long. I am marking your answer as accepted, since you are so helpful. – Lucas03 Jan 13 '16 at 20:00