我正在为OpenEdx的作品制作自己的devstack.
我从edx中删除了官方的devstack存储库,我正在修改它.
我正在尝试将论坛添加到我的堆栈中但是因为docker compose我无法运行.
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
我对运行中正确的命令感到困惑:
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'
这是工作室的命令.
forums:
command: bash -c 'source /edx/app/forum/cs_comments_service_env && ruby app.rb -p 18080'
我试过这个,但文件夹不存在.
所以我尝试使用:command:bash -c’ruby app.rb -p 18080’但是我收到此错误:
edx.devstack.forums | bash: ruby: command not found
edx.devstack.forums exited with code 127
所以,我对论坛图片感到困惑,我怎么能正确地提供它.
谁能帮我?
– 如何提供?
– 如何运行它(命令)?
更新:
我有一个新的配置:
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:password@mongo.edx: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
但我仍然有这个问题:
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
但为什么?
最佳答案
我检查了图像并找出了有助于运行容器的细节.我将列出我的调查结果如下:
> Supervisord:Supervisord已用于在容器中运行该过程.虽然容器只运行一个进程,但我没有看到在这里使用进程管理器的目的.因此,如果您正在创建图像的本地副本,请将其删除.但是现在离开它,我提供的CMD是在容器中启动进程的正确方法.
>启动:根据Docker镜像的CMD启动顺序为:
docker run => supervisord => launch script
其中启动脚本为/edx/app/forum/forum-supervisor.sh,负责:
>从/ edx / app / forum / forum_env加载环境变量.
>将目录切换到/ edx / app / forum / cs_comments_service.
>启动unicorn服务器.
此外,ruby安装在自定义路径中,如下所示:
root@8a5de1d489c5:/edx/app# which ruby
/edx/app/forum/.rbenv/shims/ruby
因此需要加载环境变量才能使用它.作为启动的一部分加载的环境变量包括:
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:password@mongo.edx: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"
使用此信息,您可以使用所需的配置运行映像.
例如,根据环境部分中的配置设置变量列表.您需要在yml文件中设置所有这些变量.一旦完成命令应该是
bash -c 'cd /edx/app/forum/cs_comments_service && exec /edx/app/forum/cs_comments_service/bin/unicorn -c config/unicorn_tcp.rb'
否则,如果您想避免编写所有这些变量,只需编写一个自定义脚本为您执行此操作,或使用默认命令启动,该命令将与这些配置结合.