Seach index not working when pushing new version of app - django

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?

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.

Related

How to visit a git branch of Django project on Nginx/uWSGI server?

I have successfully built several web sites hosted on an Nginx server using Django, uWSGI and virtualenv.
I had never used version control but now I am starting to use Git.
I understand how to create, commit and push branches.
My question is: how to make different Git branches visible at the web address of the site I'm working on?
Do I change the Nginx config file to point somewhere different?
I just updated the dev branch of my project, and of course the site does not reflect the changes.
How can I tell the server to serve the dev branch or the master branch of the project?
I would prefer to avoid a complicated system with different subdomains for different branches — I really just want the simplest thing that will work.
[update] I have found lots of pages that explain complex ways to set up staging servers etc., but I really just want to understand what is going on... there's a giant conceptual hole in my understanding about how the server interacts with a local Git project.
Right now, the Nginx config and the uWSGI config point to a folder like:
/var/www/sitefiles
That is the Django folder (inside it is sitefiles/settings.py etc.).
It is in that folder that I did git init, some commits, branching & pushes.
Does using Git mean that the Nginx and uWSGI config's should point elsewhere?
Its pretty simple goto the path of the project where git is installed and checkout to required banch and touch the wsgi file
git checkout dev
touch project/wsgi.py
or to roll back to master branch
git checkout master
touch project/wsgi.py

How to run a docker project through github code?

I have a django web application code in github. From time to time, I make necessary updates and arrangements on the repository. I have to pull the project every time and make adjustments on the docker and run on my machine.
Is there a way to run docker synchronously with the code in my github repoitory? When I make a change in github I want the docker to pull it automatically and try to run the project without interrupting.
Using hooks inside Jenkins we configure Git & Docker.
Say:
When ever we push changes to git, then jenkins job will trigger, jenkins will pull the changes and build new docker image and push the image inside docker.

How does one build an spa with webpack when deploying Docker container to Heroku

I'm developing an Aurelia Single Page App that will talk to a REST api built with Django Rest Framework.
Without containers, I would have two buildpacks, one for Node that runs a script in the package.json file and another for Python that builds the Django app.
If I push a container image, then what mechanism replaces the node buildpack that calls the script in package.json to trigger webpack to create the asset bundles?
what mechanism replaces the node buildpack that calls the script in package.json
You're not really giving any info regarding your current setup and what you've tried already, so I'll assume you already know how to run docker on heroku, and that you got your current setup to work on heroku without docker.
If you've got a script called build in your package.json that kicks off the webpack build, and start that starts a node.js express app to serve your app from the webpack output folder, you'd do something like this in your Dockerfile:
FROM node:8.9.4
RUN npm install
RUN npm run build
CMD npm run start
Of course this doesn't account for any copying and permission setting you may need to do, but that depends on your project setup.
The important bit is that you're essentially running the thing as a node app, and you need the appropriate scripts in your package.json to which you can delegate the building and running, so you only need to call one or two of those scripts from your Dockerfile. You don't want to be doing too much npm stuff there directly.

Re-build files in Ember-CLI without running server

I am planning on moving from "EmberJS" to the Ember-cli, though I have a small problem. Is it possible only to run file watcher instead of serving/using ember serve that will run local server? As I am running my PHP backend on the Google App Script I have already a local python HTTP server running in localhost:8080 I do not need another one to run in localhost:4200
If I don't run ember serve my local changes in development environment wont get updated. Is there a better way of doing this? Is it possible to use assets in the app folder when running in development environment? and use dist folder for staging/live environments?
As mentioned in the guide, you can use the build command with the --watch flag.
ember build --watch
That will keep rebuilding your changes but not actually run the server.
As for your second question:
Is it possible to use assets in the app folder when running in development environment? and use dist folder for staging/live environments?
I don't believe so. You can change the output-path property in your .ember-cli config file, but you can't have one that's specific to a certain environment. You could always write a quick script to move the files though. :)

New deployment does not show up with capistrano/passenger command-line

I make a change on the local server (something obvious, removing a <h1/>). I see it on the local machine. I then commit and push the changes and do cap deploy.
I do not see the changes when I access my staging environment.
I checked the following: Capistrano does not give me an error. I ssh onto the server and in the code, the change IS there. I restart the server manually by sudo touch tmp/restart.txt, but still I cannot see the change in the browser. Symbolic links from current/ point to the correct revision folder.
What can be causing this? The only thing I'm doing non-standard I think is that I do not deploy in production, but rather in environment called dev2. So my server start command is sudo passenger start -e dev2 -p 80 --user=ubuntu (btw, how should I deploy passenger in production? passenger start always deploys it in development, for some reason).
So to summarize, when I deploy with capistrano, I don't see the changes, although the server is restarted and the codebase does have the changes.