Skip to content

Commit

Permalink
Issue #LR-LR-449 feat: updating the readme.md file with notification …
Browse files Browse the repository at this point in the history
…service setup
  • Loading branch information
BharathwajShankar committed Jun 15, 2023
1 parent ca904dc commit c94d58e
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 24 deletions.
137 changes: 113 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,126 @@
## service-seed-without-router
Play, Akka seed project without router implementation.
# Sunbird-notification-service

Use this for creating a play-based service that leverages all internal actors. By default, runs http on port 9000.
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b963e5ed122f47b5a27b19a87d9fa6de)](https://app.codacy.com/app/sunbird-bot/sunbird-notification-service?utm_source=github.com&utm_medium=referral&utm_content=project-sunbird/sunbird-groups-service&utm_campaign=Badge_Grade_Settings)

This is the repository for notification service micro-service. It provides the APIs for notification service functionality of Sunbird.

### Note
1.In this Application , throw only org.sunbird.BaseException
The code in this repository is licensed under MIT License unless otherwise noted. Please see the [LICENSE](https://github.com/Sunbird-Lern/sunbird-notification-service/blob/master/LICENSE) file for details.
This readme file describes how to install and start groups-service in your development environment.
## Sunbird-notification-service development environment setup:
This readme file contains the instruction to set up and run the Sunbird-notification-service in your development environment.

### Build
### System Requirements

1. Execute clean install `mvn clean install`
### Prerequisites

- Java 11
- Latest Docker
- Latest Maven (Only For Mac m1 users use 3.8.8 Maven version)

### Run
1. For debug mode, <br>
`cd notification-service/service` <br>
`mvn play2:dist` <br>
`mvn play2:run`
### Prepare folders for database data and logs

2. For run mode,
`cd notification-service/service` <br>
`mvn play2:dist` <br>
`mvn play2:start`
To prepare folders for database data and logs, run the following command:

### Verify running status
```shell
mkdir -p ~/sunbird-dbs/cassandra ~/sunbird-dbs/es
export sunbird_dbs_path=~/sunbird-dbs
```

Hit the following Health check curl command
To verify the creation of folders, run:

`curl -X GET \
http://localhost:9000/health \
-H 'Postman-Token: 6a5e0eb0-910a-42d1-9077-c46f6f85397d' \
-H 'cache-control: no-cache'`
```shell
echo $sunbird_dbs_path
```

And, a successful response must be like this:
### Cassandra database setup in Docker

`{"id":"api.200ok","ver":"v1","ts":"2019-01-17 16:53:26:286+0530","params":{"resmsgid":null,"msgid":"8e27cbf5-e299-43b0-bca7-8347f7ejk5abcf","err":null,"status":"success","errmsg":null},"responseCode":"OK","result":{"response":{"response":"SUCCESS","errors":[]}}}`
1. To get the Cassandra image, use the following command:

```shell
docker pull cassandra:3.11.6
```
For Mac M1 users follow the bellow command:
```shell
docker pull --platform=linux/amd64 cassandra:3.11.6
```

For the network, you can either use an existing network or create a new one by executing the following command:
```shell
docker network create sunbird_db_network
```

2. To create the Cassandra instance, run the following command:
```shell
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
```


For Mac M1 users follow the below command:
```shell
docker run --platform=linux/amd64 -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
```

3. To verify the setup, run the following command, which will show the status of Cassandra as up and running:

```shell
docker ps -a | grep cassandra
```

## To create/load keyspaces and tables to Cassandra

Click the link [sunbird-utils-cassandra-setup](https://github.com/Sunbird-Lern/sunbird-utils/tree/release-5.3.0#readme)
and follow the steps for creating/loading the Cassandra keyspaces and tables to your development environment.

Note: It is mandatory to follow the instructions provided in the link.

4. To verify the creation of keyspaces and tables, connect to the Cassandra Docker container using SSH and run the following command:

```shell
docker exec -it sunbird_cassandra /bin/bash
```

## Sunbird-notification-service Setup

To set up the notification service, follow the steps below:

1. Clone the latest branch of the notification service using the following command:
```shell
git clone https://github.com/Sunbird-Lern/sunbird-notification-service
```

2. Set up the necessary environment variables by running the following script in the path `<project-base-path>/sunbird-notification-service`:
```shell
./scripts/notification-service-config.sh
```

3. Build the application using the following maven command in the path `<project-base-path>/sunbird-notification-service`:
```shell
mvn clean install -DskipTests
```
Make sure the build is successful before proceeding to the next step. If the build is not successful,
fix any configuration issues and rebuild the application.

4. Run the netty server using the following maven command in the path `<project-base-path>/sunbird-notification-service/service`:
```shell
mvn play2:run
```

5. Verify the database connections by running the following command:
```shell
curl --location --request GET 'http://localhost:9000/health’
```
If all connections are established successfully, the health status will be shown as 'true', otherwise it will be 'false'.
Currently, the sunbird-notification-service service is dependent on User org service for getting user and organisation information.
We are planning to implement a mock service soon for these dependencies.
To make the notification service completely working, some pre-required configuration setup is mandatory.
Follow the steps given in the link [pre-required configuration setup](https://github.com/Sunbird-Lern/sunbird-notification-service/blob/release-5.4.0/notificationsetup.md) to complete the setup.
3 changes: 3 additions & 0 deletions notificationsetup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This setup file contains the instruction to set up the required configuration for sunbird-notification service in the development environment

Follow the steps given in the link [SMS template setup](https://project-sunbird.atlassian.net/wiki/spaces/UM/pages/3316809958/How+to+Set+up+SMS+Template) to do the sms template setup.
7 changes: 7 additions & 0 deletions scripts/notification-service-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export sunbird_us_system_setting_url=/api/data/v1/system/settings/list
export sunbird_us_org_read_url=/v1/org/read
export sunbird_msg_91_baseurl=http://api.msg91.com/
export sunbird_msg_91_get_url=api/sendhttp.php?
export sunbird_msg_91_post_url=api/v2/sendsms
export sunbird_fcm_url=https://fcm.googleapis.com/fcm/send
export [email protected]

0 comments on commit c94d58e

Please sign in to comment.