Open edX tips & tricks (for pre Tutor era)

Open edX expert and open-source enthusiast.
Change access permission of pem file
sudo chmod 400 my_private_key.pem
SSH into your server
ssh -i my_private_key.pem ubuntu@<ip_of_your_server>
Set the OPENEDX_RELEASE variable
# For native installation
export OPENEDX_RELEASE=open-release/maple.master
# For devstack docker installation
export OPENEDX_RELEASE=maple.master
Check logs
Request logs and errors from the LMS & CMS. If you're getting a 500 error on a certain request, look here.
sudo tail -f /edx/var/log/lms/edx.log sudo tail -f /edx/var/log/cms/edx.logStartup error messages and debug output from the running LMS & CMS Django process. If you're getting a startup error, look here.
sudo tail -f /edx/var/log/supervisor/lms-stderr.log sudo tail -f /edx/var/log/supervisor/cms-stderr.logDebug output from the supervisor task manager. If you make changes to the supervisor task definitions, look here.
sudo tail -f /edx/var/log/supervisor/supervisord.logErrors from the Nginx proxy server that front-ends both the LMS and CMS. Mostly access or configuration-related errors. If you're getting a 4xx or 5xx error, look here
sudo tail -f /edx/var/log/nginx/error.logAccess logs for all requests to the server. If you want to see apache style logs for every request your server is getting, look here.
sudo tail -f /edx/var/log/nginx/access.logError from LMS workers. If you're getting worker errors, look here.
sudo tail -f /edx/var/log/supervisor/lms_default_1-stderr.log sudo tail -f /edx/var/log/supervisor/lms_high_1-stderr.log sudo tail -f /edx/var/log/supervisor/lms_high_mem_1-stderr.logError from CMS workers. If you're getting worker errors, look here.
sudo tail -f /edx/var/log/supervisor/cms_default_1-stderr.log sudo tail -f /edx/var/log/supervisor/cms_high_1-stderr.logErrors from Forum service. If you're getting any errors in Forum, look here.
sudo tail -f /edx/var/log/supervisor/forum-stderr.logOn devstack docker installation
make <service_name>-logs # For LMS make lms-logs
Running your server in debugging mode
sudo /edx/bin/supervisorctl stop lms
# For ironwood and earlier releases
sudo -u www-data /edx/bin/python.edxapp /edx/app/edxapp/edx-platform/manage.py lms runserver 8000 --settings production
# For koa and later releases
cd /edx/app/edxapp/edx-platform
source /edx/app/edxapp/edxapp_env
sudo -E -u www-data /edx/app/edxapp/venvs/edxapp/bin/python manage.py lms runserver 8000 --settings production
# Once you are done with the debugging
Ctrl + c
sudo /edx/bin/supervisorctl start lms
Check your configurations
Most configuration parameters for the app.
Feature flags
backend server locations
theme related settings
Authentication parameters for the app
API Keys
Database passwords
occasional settings that are paired with authentication
# For ironwood and earlier releases
sudo nano /edx/app/edxapp/lms.env.json
sudo nano /edx/app/edxapp/cms.env.json
sudo nano /edx/app/edxapp/lms.auth.json
sudo nano /edx/app/edxapp/cms.auth.json
# For juniper and later releases
sudo nano /edx/etc/lms.yml
sudo nano /edx/etc/studio.yml
Install nano in lms shell in devstack docker
make lms-shell
apt-get install nano
manage.py commands
List all manage.py commands
# For Native Installation sudo -H -u edxapp bash source ~/edxapp_env cd ~/edx-platform ./manage.py lms --settings production help # For devstack docker installation make lms/studio-shell ./manage.py lms --settings devstack_docker helpDelete a course in Open edX
./manage.py cms delete_course course-v1:edX+DemoX+Demo_Course --settings <your_settings>Open Django shell (InteractiveConsole)
./manage.py lms shell --settings <your_settings>Compile SCSS files
./manage.py lms compile_sass --settings <your_settings>Collect static files
# For LMS ./manage.py lms --settings <your_settings> collectstatic --ignore "fixtures" --ignore "karma_*.js" --ignore "spec" --ignore "spec_helpers" --ignore "spec-helpers" --ignore "xmodule_js" --ignore "geoip" --ignore "sass" --noinput > /dev/null # For CMS ./manage.py cms --settings <your_settings> collectstatic --ignore "fixtures" --ignore "karma_*.js" --ignore "spec" --ignore "spec_helpers" --ignore "spec-helpers" --ignore "xmodule_js" --ignore "geoip" --ignore "sass" --noinput > /dev/nullCopy programs data into the LMS
./manage.py lms cache_programs --settings <your_settings>Compile Translation files
./manage.py lms compilejsi18n --settings <your_settings> ./manage.py lms compilemessages --settings <your_settings>Reindex courses
# reindexes courses with provided keys ./manage.py cms reindex_course <course_id_1> <course_id_2> ... # reindexes all available courses ./manage.py cms reindex_course --all
Refresh course metadata in the discovery
Discovery maintains metadata for program and course information. To ingest metadata into discovery from LMS, e-commerce, and the marketing site run the following commands in devstack to enter the discovery shell and refresh the metadata.
make discovery-shell
./manage.py refresh_course_metadata
Supervisor commands on native installation
Restart Supervisor service
sudo systemctl restart supervisorSee what services are running
sudo /edx/bin/supervisorctl statusRestarting services
# LMS sudo /edx/bin/supervisorctl restart lms # Workers sudo /edx/bin/supervisorctl restart edxapp_worker:Stop services
# LMS sudo /edx/bin/supervisorctl stop lms # Workers sudo /edx/bin/supervisorctl stop edxapp_worker:
Update Assets
# To update lms and cms assets
paver update_assets --settings <your_settings>
# To update lms assets
paver update_assets lms --settings <your_settings>
# To update cms assets
paver update_assets cms --settings <your_settings>
MySQL Access
mysql -h <host> -u <username> -p<password>
Create MySQL user and grant privileges
mysql -u root
use edxapp
CREATE USER 'edxapp001'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON edxapp.* TO 'edxapp001'@'%';
use edxapp_csmh
CREATE USER 'edxapp_cmsh001'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON edxapp_csmh.* TO 'edxapp_cmsh001'@'%';
CREATE USER 'migrate'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON edxapp.* TO 'migrate'@'%';
GRANT ALL PRIVILEGES ON edxapp_csmh.* TO 'migrate'@'%';
# if required
FLUSH PRIVILEGES
MongoDB Access
mongo --port 27017 -u admin -p password --authenticationDatabase admin
Install requirements in edx-platform
cd ~/edx-platform
make requirements
Renew SSL Cert
certbot-auto --renew-by-default
References:
https://openedx.atlassian.net/wiki/spaces/OpenOPS/pages/60227913/Managing+OpenEdX+Tips+and+Tricks
https://openedx.atlassian.net/wiki/spaces/LEARNER/pages/171180253/Program+Bundling+Setup#ProgramBundling-Settingupbundlingonthelocalenvironment
https://openedx.atlassian.net/wiki/spaces/OpenOPS/pages/49873839/Debugging+Edxapp



