Automatically setup Apache Solr with Django - Oscar on AWS Elastic Beanstalk

≯℡__Kan透↙ 提交于 2019-12-08 17:51:19

问题


I need to ensure that Apache Solr is installed with my django-oscar application, and have been using these instructions with an .ebextensions config file to automatically install Solr and rebuild the index.

Here is the .ebextensions/03_solr.config

container_commands:
  01_install_solr:
    command: "wget http://archive.apache.org/dist/lucene/solr/4.7.2/solr-4.7.2.tgz &&
    tar xzf solr-4.7.2.tgz &&
    cd solr-4.7.2.example/solr/collection1 && 
    mv conf conf.original && 
    ln -s /opt/python/current/app/deploy/solr conf &&
    cd ../.. && 
    java -jar start.jar"
  02_rebuild_index:
    command: "python manage.py rebuild_index --noinput"

What do I need to add/update here to get the solr to install automatically on

eb deploy

?

Update: changed the bash to a single command. It looks like the process is completing, but on executing java -jar start.jar, the .ebextensions/03_solr.config task executes the

org.eclipse.jetty.server.AbstractConnector - Started SocketConnector@0.0.0.0:8983

This process should really be a background process, as currently it is causing the deploy to hang, and timeout without deploying the new application. According to this SO post, to start a delayed job AFTER the new application version is deployed takes some work. Any suggestions? To clarify:

Run the

java -jar start.jar

command as a non-blocking, background process for EB?


回答1:


So the answer did end up being the need to use the post deployment hooks, as described. Terminating and restarting the EB EC2 instance and a fresh deploy solved the issue.

container_commands:
  01_install_solr:
    command: "cd /opt/python/current/app &&
    wget http://archive.apache.org/dist/lucene/solr/4.7.2/solr-4.7.2.tgz &&
    tar xzf solr-4.7.2.tgz &&
    cd solr-4.7.2/example/solr/collection1/ &&
    cp -r conf conf.original &&
    ln -s /opt/python/current/app/deploy/solr conf"
    leader_only: true
  02_rebuild_index:
    command: "python manage.py rebuild_index --noinput"
    leader_only: true
commands:
  create_post_dir:
    command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
    ignoreErrors: false

  files:
    "/opt/elasticbeanstalk/hooks/appdeploy/post/start_solr.sh":
      mode: "000755"
      owner: root
      group: root
      content: |
        #!/usr/bin/env bash
        nohup java -jar /opt/python/current/app/solr-4.7.2/example/start.jar queue:work --daemon >/dev/null 2>&1 &



回答2:


Note that each of these steps is executed in the default folder, so issuing a cd command is ineffective. You should run all those steps in a single command rather than multiple ones.
step 04 will fail as it starts in the default directory rather than the solr one



来源:https://stackoverflow.com/questions/34126387/automatically-setup-apache-solr-with-django-oscar-on-aws-elastic-beanstalk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!