Check running tomcat process

To check running Tomcat process on Ubuntu, run the following command:

$ ps -ef | grep tomcat

Note: column 2 is process number.

 

And also kill all

$ ps -ef | grep tomcat | awk ‘{print $2}’ | xargs kill -9

To list out processes comsume memory sorted decending

ps aux --sort -rss
By luanvm Posted in Unix

GIT: fork a new repository from a tag

Create a new repo from a tag in order to start coding.

$ git remote add horus_remote git@bitbucket.org:luan_vominh/edx-platform-gingko.git
$ git fetch horus_remote
$ git add --all
$ git push -u horus_remote master tags/open-release/ginkgo.1

Next, in case we want to use the new repo for coding, just checkout new branch:

$ git checkout -b horus_remote

 

Next, in case we add new files and want to push to the new repo:

$ git add --all
$ git commit -m 'your message'
$ git push --set-upstream origin horus_remote

In above example, i want to fork a new repository from EDX ginkgo.1 release.

By luanvm Posted in EDX, GIT

EDX: Enable and Active a theme

The objective of this post is to guide to enable an exisitng theme, then active it.

EDX version: ficus devstack.

 

Enable a theme

Open EDX comes with few existing themes:

  • edx.org
  • stanford-style
  • red-theme
  • edge.edx.org

Firstly, we need to enable a theme first: red-theme in my case.

$ vagrant ssh
$ sudo su edxapp
$ cd ~
$ vi lms.env.json

 

Update following three fields:

"ENABLE_COMPREHENSIVE_THEMING": true


DEFAULT_SITE_THEME": "red-theme",

    "COMPREHENSIVE_THEME_DIRS": [

        "/edx/app/edxapp/edx-platform/themes"

    ],

"THEME_NAME": "red-theme",

Restart the server.

Until this step, the red-theme theme is enabled and ready to use. However, our site is still not using this theme. We need to apply the theme.

Apply Theme

We need to apply theme to a site, this is done via /admin url.

Login http://localhost:8000/admin with an admin account. The default installation does not come with an admin account. We MUST create a new one. Please see the sesction below.

Create a new site, example: example.com

url: http://localhost:8000/admin/sites/site/

Create a new theme:

url: http://localhost:8000/admin/theming/sitetheme/

naming new theme with the name set up in lms.env.json. In my case: red-theme.

 

In case you want to swith to edx.org theme for example, just update the site theme via http://localhost:8000/admin/theming/sitetheme/

and it will be impacted immediately, no need to restart the server.

 

Create an admin user:

Run following scripts line by line:

$ vagrant ssh
$ sudo su -s /bin/bash edxapp
$ /edx/bin/python.edxapp /edx/bin/manage.edxapp lms manage_user staff3 staff3@example.com --staff --superuser --settings=aws

then we need to set the password

$ /edx/bin/python.edxapp ./manage.py lms --settings aws changepassword staff3

 

 

Reference link: https://edx.readthedocs.io/projects/edx-installing-configuring-and-running/en/latest/configuration/changing_appearance/theming/enable_themes.html

 

By luanvm Posted in EDX

Install EDX Ginkgo release, full-stack version on Ubuntu 16.

Below are my steps to install full-stack version of EDX Ginkgo release:

Installation

 $ mkdir fullstack
 $ cd fullstack
 $ export OPENEDX_RELEASE="open-release/ginkgo.1"
 $ curl -OL https://raw.github.com/edx/configuration/$OPENEDX_RELEASE/util/install/install_stack.sh
 $ bash install_stack.sh fullstack

Run fullstack

$ vagrant up
$ vagrant ssh

LMS: http://192.168.33.10/ (user: staff@example.com – password: edx)
Studio: http://192.168.33.10:18010/
Page admin: http://192.168.33.10/admin (user: admin@example.com – password: password)

Create a superuser account

 $ cd /edx/app/edxapp/edx-platform
 $ sudo -u www-data /edx/bin/python.edxapp ./manage.py lms --settings aws create_user -s -p edx -e admin@example.com
 $ sudo -u www-data /edx/bin/python.edxapp ./manage.py lms --settings aws changepassword admin
 $ sudo -u www-data /edx/bin/python.edxapp ./manage.py lms --settings aws shell

copy and paste following commands line by line

>> from django.contrib.auth.models import User
 >> me = User.objects.get(username="admin")
 >> me.is_superuser = True
 >> me.is_staff = True
 >> me.save()
 >> exit()

Restart service

After user is created, we should restart servers.

//--lms, cms
 $ sudo /edx/bin/supervisorctl restart edxapp:
 
 //ecommerce
 $ sudo /edx/bin/supervisorctl restart edxapp: ecommerce:

//forum
 $ sudo /edx/bin/supervisorctl restart forum:

Change IP address

if you don't want to use the above default port: 192.168.33.10, pick another one that suitable your LAN network, and edit Vagrantfile in fullstack directory to change line below:
 config.vm.network :private_network, ip: "192.168.33.10"

to

 config.vm.network :public_network, ip: "192.168.1.50", use_dhcp_assigned_default_route: true

 

That’s all.

By luanvm Posted in EDX

GIT tips

Check status:

$ git status

Lit local changes

$ git diff

Git commit all changes

$ git add -A && git commit -m 'update title'

Git – reset all local commits, that are not pushed yet:

$ git reset –hard origin/master

Command to merge branch but ignore a file

 
$ git merge --no-commit stroke_study
$ git reset HEAD scripts/horusValidationRules.js
$ git checkout scripts/horusValidationRules.js
$ git commit -m "merged stroke_study"
$ git push

 

By luanvm Posted in GIT

EDX Tip 2 – Working with localization

The object of this post is to guide how to run EDX in other language, it is Vietnamese in my case.

I have followed the guideline at https://github.com/edx/edx-platform/wiki/Internationalization-and-localization

Steps:

$ vagrant ssh

$ sudo su edxapp
create ~/.transifex file with following content:
 [https://www.transifex.com]
 hostname = https://www.transifex.com
 username = luanvm
 password = <your_password>
 token =

Your account in transfex must be joined to edx project. If not, you cannot pull new languages.

pull your language, my case is Vietnamese:

$ tx pull -l vi

compile language:

$ paver i18n_fastgenerate

In case you want to update message locally, just update .po files then re-compile:
$ paver i18n_fastgenerate

 

That’s all.

By luanvm Posted in EDX

EDX Tip – connect to Vagrant via FileZilla

The object of this post is guide how to connect to Vagrant instance using FileZila to transfer / update file in remote EDX running instance.

Before using Filezila, we should use Teminal first.

Startup Vagrant

$ vagrant up

SSH to Vagrant

$ vagrant ssh

Check running ssh connections

$ ps aux | grep ssh

Output looks likes:

Luans-MacBook-Pro:home luan$ ps aux | grep ssh

luan             3755   0.0  0.0  2464336   2188 s002  S+   11:18AM   0:01.72 ssh vagrant@127.0.0.1 -p 2222 -o Compression=yes -o DSAAuthentication=yes -o LogLevel=FATAL -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /Users/luan/.vagrant.d/boxes/ficus-devstack-2017-02-07/0/virtualbox/vagrant_private_key

Attemp to ssh vagrant from other directory:

ssh vagrant@127.0.0.1 -p 2222

Enter default password: vagrant

So the key point is vagrant port is 2222 instead of 22 as normal. FileZila confiuration will look like:

 

In case we need to edit file that owner is edxapp , we should connect to fileZila with edxapp user.

If we dont know edxapp’s password, we should change it:

$ sudo su passwd edxapp

Then type your password.

 

That’s all

 

DHIS2-import database to an existing running instance

To import an existing database from your localhost to your deployment server, follow steps below please:

  1. export your database at localhost
  2. scp database, war file (if any) to your server
  3. in remote server, run following commands:
$ sudo -su postgres psql
# drop database wwf1;
Then create a new database with the same name wwf1
# create database wwf1 owner wwf1;
Then import your db file to the new database created
$ sudo -su postgres psql wwf1 < /root/dbfiles/local_wwf1_20170526.dump
Finally we need to grant all permission to wwf1. 
If we miss this step, we cannot start the instance.

# GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO wwf1;

Next is update owner of hibernate_sequence to wwf1.
To see all sequences owners, run: 
# \d
Update sequence owner with command:
# alter sequence hibernate_sequence owner to wwf1;

Note:

Cursor #: meaning that you are logged in posgres
Curso $: meaning that you are in command shell window, not in Posgres command window

Solution 2
After we create a new database in above step. We can use text editor 
to update  dump file to replace old owner with a new one to. With this way
we do not need to run scripts to grant privileges.
By luanvm Posted in DHIS2

Simple commands for working with mongo in EDX

EDX is using mongodb, and mysql. I am using devstack version installed on MacOSX.

I was attempting to connect to mongo db to discover which inside it. I spent a couple days and always got the same issues as below:

vagrant@vagrant:/edx/app/edxapp$ mongo

MongoDB shell version: 2.6.12

connecting to: test

2017-05-23T04:53:57.796+0000 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused

2017-05-23T04:53:57.798+0000 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146

exception: connect failed

I also tried following commands:

$ mongo admin

$ mongo edxapp

$ mongo localhost/edxapp -username edxapp -password edxapp

 

All printed the same error message.

I thought that the mongo db was running because i was doing debug with PyCharm that time. So i was stuck there.

 

Fortunately i found the solution next day when trying to start mongo db first. Then try above commands. and it works fine.

 

So, to start developing EDX, we should check where mongodb is running or not.

 

Check whether mongo is running or not

$ sudo service mongod status

My db is down

● mongod.service - High-performance, schema-free document-oriented database

   Loaded: loaded (/etc/systemd/system/mongod.service; enabled; vendor preset: e

   Active: inactive (dead) since Tue 2017-05-23 04:43:27 UTC; 1min 18s ago

     Docs: https://docs.mongodb.org/manual

  Process: 14428 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (co

 Main PID: 14428 (code=exited, status=0/SUCCESS)

May 23 04:31:17 vagrant systemd[1]: Started High-performance, schema-free docume

May 23 04:43:27 vagrant systemd[1]: Stopping High-performance, schema-free docum

May 23 04:43:27 vagrant systemd[1]: Stopped High-performance, schema-free docume

 

Start mongo

$ sudo rm /edx/var/mongo/mongodb/mongod.lock
$ sudo -u mongodb mongod --dbpath /edx/var/mongo/mongodb --repair --repairpath /edx/var/mongo/mongodb
$ sudo systemctl start mongod.service

 

Stop mongo

$ sudo service mongod stop