Note: Before completing this guide, make sure you have completed the general onboarding guide in the base mojaloop repository.
- Prerequisites
- Installing and Building
- Running Locally
- Running Inside Docker
- Testing
- Common Errors/FAQs
If you have followed the general onboarding guide, you should already have the following cli tools installed:
brew(macOS), [todo: windows package manager]curl,wgetdocker+docker-composenode,npmand (optionally)nvm
In addition to the above cli tools, you will need to install the following to build and run the central-event-processor:
#none - you have everything you need![todo]
[todo]
Firstly, clone your fork of the central-event-processor onto your local machine:
git clone https://github.com/<your_username>/central-event-processor.gitThen cd into the directory and install the node modules:
cd central-event-processor
npm installIf you run into problems running
npm install, make sure to check out the Common Errors/FAQs below.
In this method, we will run core dependencies (mongodb, kafka) inside of docker containers, while running the central-event-processor server on your local machine.
Alternatively, you can run the
central-event-processorinside ofdocker-composewith the rest of the dependencies to make the setup a little easier: Running Inside Docker.
1. Run the dependencies in docker-compose:
# start the dependencies inside of docker
docker-compose up mongo kafka
3. Configure the default files and run the server
# start the server
npm run startUpon running npm run start, your output should look similar to:
> central-event-processor@6.2.0 start /<path_to>/central-event-processor
> WITH_SASL=0&&LD_LIBRARY_PATH=$PWD/node_modules/node-rdkafka/build/deps&& node app.js
2019-06-03T07:23:27.850Z - info: Connection with database succeeded.
2019-06-03T07:23:27.863Z - info: CreateHandle::connect - creating Consumer for topics: [topic-notification-event]
2019-06-03T07:23:28.116Z - info: CreateHandle::connect - successful connected to topics: [topic-notification-event]
healthcheck is listening on port 3080
We use docker-compose to manage and run the central-event-processor along with its dependencies with one command.
Note: Before starting all of the containers however, start the
mysqlcontainer alone, to give it some more time to set up the necessary permissions (this only needs to be done once). This is a short-term workaround because thecentral-ledger(which is a dependency ofcentral-event-processsor) doesn't retry it's connection to MySQL.
1. First run the mysql container, then run the test of the containers
docker-compose up mysql #first time only - the initial mysql load takes a while, and if it's not up in time, the central-ledger will just crash
npm run docker:upThis will do the following:
docker pulldown any dependencies defined in thedocker-compose.ymlfiledocker buildthecentral-event-processorimage based on theDockerfiledefined in this repo- run all of the containers together (
central-ledger,ml-api-adapter,central-event-processor)
You can run docker-compose in 'detached' mode as follows:
npm run docker:up -- -dAnd then attach to the logs with:
docker-compose logs -fWhen you're done, don't forget to stop your containers however:
npm run docker:stopWe use npm scripts as a common entrypoint for running the tests.
# unit tests:
npm run test:unit
# integration tests
npm run test:integration
# check test coverage
npm run test:coverageNote: Make sure you have installed Postman and cloned the
mojaloop/postmanrepo, which contains all the required collections and environments. You can find detailed instructions for this in the general onboarding guide.
ml-api-adapterandcentral-ledgerservices running (follow the Running Inside Docker guide to get these services up and running)- Optionally, run
central-timeout,cental-settlementas well.
- Import the Mojaloop v0.1 draft collection, and open
API Examples>mojaloop v1.0>6.a. Transfer Prepare Request - Click Send
- If you get a valid response, continue to the next step, otherwise it reveals an issue in your configuration.
- Select the
7.a. Transfer Fulfil Requestand perform a corresponding fulfilment request - You can check the database to see the transfer state, status changes, positions and other such information. After this if everything looks good, you should be ready to go.
Resolved by installing v2.0.3 npm install sodium@2.0.3
Resolved by running CXX='clang++ -std=c++11 -stdlib=libc++' npm rebuild
Undefined symbols for architecture x86_64:
"_CRYPTO_cleanup_all_ex_data", referenced from:
_rd_kafka_transport_ssl_term in rdkafka_transport.o
"_CRYPTO_num_locks", referenced from:
........
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Resolved by installing openssl brew install openssl and then running:
export CFLAGS=-I/usr/local/opt/openssl/include
export LDFLAGS=-L/usr/local/opt/openssl/lib
npm install