Skip to content

Latest commit

 

History

History
109 lines (104 loc) · 3.75 KB

README.md

File metadata and controls

109 lines (104 loc) · 3.75 KB

sunbird-course-service

​ Repository for Batch Service ​

sunbird-course-Service local setup

This readme file contains the instruction to set up and run the sunbird-course-service in local machine. ​

Prerequisites:

Java 11, Maven - Latest, Cassandra 3.11.6, ES 6.8.11, Redis 4.0.0, GIT, Postman, IntelliJ Editor, Docker - Latest ​

Create folders for database data and logs

mkdir -p ~/sunbird-dbs/cassandra ~/sunbird-dbs/es
export sunbird_dbs_path=~/sunbird-dbs

Cassandra database setup in docker:

​ i. Get the cassandra image using below command

docker pull cassandra:3.11.6

ii. For the network, we can use the existing network or create a new network using the following command and use it.

docker network create sunbird_db_network

iii. Run Cassandra

docker run -p 9042:9042 --name sunbird_cassandra -v $sunbird_dbs_path/cassandra/data:/var/lib/cassandra -v $sunbird_dbs_path/cassandra/logs:/opt/cassandra/logs -v $sunbird_dbs_path/cassandra/backups:/mnt/backups --network sunbird_db_network -d cassandra:3.11.6

iv. Copy the sunbird_courses.cql file from github (https://github.com/Sunbird-Lern/sunbird-course-service/blob/bootcamp/scripts/sunbird_courses.cql) to /sunbird-dbs/cassandra/backups folder.

OR

chmod -R 777 sunbird-dbs/cassandra

wget -O sunbird-dbs/cassandra/backups/sunbird_courses.cql" https://raw.githubusercontent.com/Sunbird-Lern/sunbird-course-service/bootcamp/scripts/sunbird_courses.cql

v. To start the Cassandra cypher shell run the below command.

docker exec -it sunbird_cassandra cqlsh

vi. Load database schema by executing below command in cypher shell.

source '/mnt/backups/sunbird_courses.cql'

Elasticsearch database setup in docker:

i. Get the ES image using below command:

docker pull elasticsearch:6.8.11

ii. Run ES

docker run -p 9200:9200 --name sunbird_es -v $sunbird_dbs_path/es/data:/usr/share/elasticsearch/data -v $sunbird_dbs_path/es/logs://usr/share/elasticsearch/logs -v $sunbird_dbs_path/es/backups:/opt/elasticsearch/backup -e "discovery.type=single-node" --network sunbird_db_network -d docker.elastic.co/elasticsearch/elasticsearch:6.8.11

chmod -R 777 sunbird-dbs/es

iii. ES Indices and Mappings Create course_batch index and mapping using the /indices/course-batch.json and /mappings/course-batch-mapping.json in below link https://github.com/project-sunbird/sunbird-devops/tree/master/ansible/roles/es-mapping/files PUT http://localhost:9200/<indices_name> Body : <indices_json_content> PUT http://localhost:9200/<indices_name>/_mapping/_doc Body : <mapping_json_content> ​

Redis setup in docker:

i. Get the Redis image using below command:

docker pull redis:4.0.0

ii. Run Redis

docker run --name sunbird_redis -d -p 6379:6379 redis:4.0.0

Batch Service Repo setup:

Repository url : https://github.com/Sunbird-Lern/sunbird-course-service Branch : bootcamp ​ i. Checkout the bootcamp branch code from github after forking the repository. ​ ii. Update the lms-service.sh file in the scripts folder with configuration values to setup environment variables and run it to export the values or add the variables to bashrc or bashprofile.

./scripts/lms-service.sh

iii. Build using maven from sunbird-course-service folder

mvn clean install -DskipTests

iii. Run the service from sunbird-course-service/service folder

mvn play2:run

iv. Use the below curl to check the service health

curl --location --request GET 'http://localhost:9000/health'

​ The code in this repository is licensed under MIT License unless otherwise noted. Please see the LICENSE file for details.