jeudi 25 juin 2015

Automatic restart of SolR after Elastic Beanstalk deployment

I have a RoR application on AWS. My app is using SolR for the search engine, but after each deployment, the app is unable to index again. So I have to reset permissions and restart Solr manually with:

chmod 777 -R /solr /tmp /log
RAILS_ENV=production rake sunspot:solr:stop # or I kill the processus if it doesn't work :D 
RAILS_ENV=production rake sunspot:solr:start
RAILS_ENV=production rake sunspot:reindex

Now i'm trying to setup it as an eb extension to automate the deployment. Here is what I tried in my .ebextensions/deploy.config:

container_commands:
  1_change_permissions:
    command: chmod 700 .ebextensions/setup.sh 
  2_restart_solr:
    command: bash .ebextensions/setup.sh 

And here is the setup.sh script:

#!/bin/bash
chmod 777 -R solr/ log/ tmp/
RAILS_ENV=production rake sunspot:solr:restart

The result is the deployment doesn't fail but, only the permissions are changed correctly, and the solr service is running but when I try to index something, it fails (the querying works fine).

I also tried to stop the server before the app is deployed by adding a commands block in my .ebextensions/deploy.config (and I changed my sh script to start the service instead of restart) :

commands:
  1_stop_solr:
    command: cd /var/app/current & RAILS_ENV=production rake sunspot:solr:stop

I got this error (I don't know from where it is executed):

[2015-06-25T09:51:35.510Z] INFO [13207] - [CMD-AppDeploy/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild/prebuild_0_My_First_Elastic_Beanstalk_Application/Command 1_stop_solr] : Activity execution failed, because: rake aborted! couldn't find HOME environment -- expanding `~'




Aucun commentaire:

Enregistrer un commentaire