Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct pulling edxops/forums way

I'm making my own devstack for works with OpenEdx.

I pulled the official devstack repository from edx and i'm modifying it.

I'm trying add forums to my stack but i can't run in since docker compose.

I added this to composer file:

forums:
    command: bash -c 'source /edx/app/forum/cs_comments_service_env && ruby app.rb -p 18080'
    container_name: edx.devstack.forums
    depends_on:
      #   - xqueue:xqueue
      - mongo
      - elasticsearch
      # - rabbitmq:rabbitmq
      - mysql
      - memcached
    environment:
      CACHE_LOCATION: edx.devstack.memcached:12211
      DB_HOST: edx.devstack.mysql
      TEST_ELASTICSEARCH_URL: "http://edx.devstack.elasticsearch:9200"
    image: edxops/forums:latest
    ports:
      - 4567:4567

I'm confuse about wich the correct command in run:

studio:
    command: bash -c 'source /edx/app/edxapp/edxapp_env && python /edx/app/edxapp/edx-platform/manage.py cms runserver 0.0.0.0:18010 --settings devstack_docker'

This is the command for studio.

forums:
    command: bash -c 'source /edx/app/forum/cs_comments_service_env && ruby app.rb -p 18080'

I tried with this but the folder doesn't exist.

So i tried with: command: bash -c 'ruby app.rb -p 18080' but i get this error:

edx.devstack.forums | bash: ruby: command not found
edx.devstack.forums exited with code 127

So, i'm confused about the forums image and about how can i provide it for works correctly.

Can anyone help me? - How provide it? - How run it(command)?

UPDATE:

I have a new configuration:

forums:
    command: bash -c 'cd /edx/app/forum/cs_comments_service && exec /edx/app/forum/cs_comments_service/bin/unicorn -c config/unicorn_tcp.rb'
    container_name: edx.devstack.forums
    depends_on:
      # - xqueue:xqueue
      - mongo
      - elasticsearch
      # - rabbitmq:rabbitmq
      - mysql
      - memcached
    environment:
      CACHE_LOCATION: edx.devstack.memcached:12211
      DB_HOST: edx.devstack.mysql
      SEARCH_SERVER: "http://edx.devstack.elasticsearch:9200"
      TEST_ELASTICSEARCH_URL: "http://edx.devstack.elasticsearch:9200"
      MONGOHQ_URL: "mongodb://cs_comments_service:[email protected]:27017/cs_comments_service"
      GEM_PATH: "/edx/app/forum/.gem"
      GEM_HOME: "/edx/app/forum/.gem"
      RBENV_ROOT: "/edx/app/forum/.rbenv"
    image: edxops/forum:latest
    ports:
      - 4567:4567

But i still have this issue:

docker-compose logs -f --tail=500 | grep edx.devstack.forums
Attaching to edx.devstack.forums, edx.devstack.chrome, edx.devstack.firefox, edx.devstack.credentials, edx.devstack.discovery, edx.devstack.elasticsearch, edx.devstack.ecommerce, edx.devstack.studio, edx.devstack.lms, edx.devstack.memcached, edx.devstack.mysql, edx.devstack.mongo
edx.devstack.forums | /usr/bin/env: ‘ruby’: No such file or directory

But, why?

like image 824
SalahAdDin Avatar asked May 29 '17 14:05

SalahAdDin


Video Answer


1 Answers

I inspected the image and figured out the details that will be helpful in running the container. I will list down my findings as below:

  • Supervisord: Supervisord has been used to run the process in the container. Although the container is only running a single process I don't see a purpose of using a process manager here. So, if you are creating a local copy of the image just get rid of it. But for now leave it, the CMD I am providing is the right way of launching a process in a container.

  • Startup: The startup sequence as per CMD of docker image is:

    docker run => supervisord => launch script
    

    where launch script is /edx/app/forum/forum-supervisor.sh responsible for :

    1. Loading environment variables from /edx/app/forum/forum_env.
    2. Switching the directory to /edx/app/forum/cs_comments_service.
    3. Starting the unicorn server.

Also, ruby is installed at a custom path as follow:

    root@8a5de1d489c5:/edx/app# which ruby 
    /edx/app/forum/.rbenv/shims/ruby

So environment variables need to loaded to use it. The environment variables loaded as part of startup include:

export LISTEN_HOST="0.0.0.0"
export NEW_RELIC_APP_NAME="default_env-default_deployment-forum"
export DATA_DIR="/edx/var/forum"
export LISTEN_PORT="4567"
export MONGOHQ_URL="mongodb://cs_comments_service:[email protected]:27017/cs_comments_service"
export GEM_PATH="/edx/app/forum/.gem"
export RACK_ENV="staging"
export WORKER_PROCESSES="4"
export NEW_RELIC_ENABLE="False"
export SINATRA_ENV="staging"
export SEARCH_SERVER="http://es.edx:9200"
export PATH="/edx/app/forum/cs_comments_service/bin:/edx/app/forum/.rbenv/bin:/edx/app/forum/.rbenv/shims:/edx/app/forum/.gem/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export API_KEY="password"
export HOME="/edx/app/forum"
export GEM_HOME="/edx/app/forum/.gem"
export RBENV_ROOT="/edx/app/forum/.rbenv"

With this information you can run the image with required configuration.

For example set the list of variables accordingly to your configuration in the environment section. You will need to set all of these variables in yml file. Once done the command should be

bash -c 'cd /edx/app/forum/cs_comments_service && exec /edx/app/forum/cs_comments_service/bin/unicorn -c config/unicorn_tcp.rb'

else if you want to avoid writing all these variables just write a custom script to do it for you or launch with default command which will be married to these config.

like image 107
Qasim Sarfraz Avatar answered Sep 20 '22 12:09

Qasim Sarfraz