Getting Started - GiteshDalal/serve GitHub Wiki

Prerequisites

  1. Java 1.8 JDK
  2. Lombok for IDE (Recommended IDE - Intellij IDEA Community Edition)
  3. Docker Compose
  4. Vault
  5. MySQL 5.7
  6. GitBash - For windows only

Setup

  1. Download the latest starter project source code from Releases section or clone this repository
  2. Extract the source code and then open terminal/console in your working directory
  3. Run cd engine/ && ./gradlew clean build for linux or cd engine\ && gradlew.bat clean build for windows. This will generate engine/build/libs/engine-1.0.0.jar file which is used by gradle to build serve microservices
  4. Import serve/ as a gradle project into IDE. In case of Intellij, check following boxes while importing project : Use auto-import and create directories for empty content roots automatically
  5. Run cd ../serve/ && ./gradlew clean build -x test using linux terminal or cd ..\serve\ && gradlew.bat clean build -x test on windows console

Initialize System

  • Updating centralized configuration - The configservice is used for centralized configurations. By default it is making use of serve-configuration repository. You can change it by updating spring.cloud.config.server.git.uri property in file configservice > src > main > resources > bootstrap.yml

  • Updating security configuration - All the security-related configurations, i.e. keys, usernames, passwords etc, are stored using Vault. On startup Vault imports configurations using json files located in vault folder. (Important: All json files should be updated with real configuration values before starting the microservices.)

  • Vault authentication - All microservices which are dependent on Vault for configuration have vault related properties in configuration file resources > bootstrap.yml. One of these is an authentication token which is used to connect to Vault.

Default auth token: 47d1d790-0cce-384f-5a28-3cf2eb9e5489

Starting microservices

With Docker

  • Linux/Mac - Open terminal in serve/ folder and then run following command
sudo docker-compose up
  • Windows - Run powershell as an administrator, navigate to serve/ folder, and then enter following command
docker-compose up

Manually (on local)

  1. Start Vault in development mode. Run following command in terminal/powershell (-dev-root-token-id argument lets vault know that instead of generating a token, it should use the mentioned one)
vault server -dev -dev-root-token-id=47d1d790-0cce-384f-5a28-3cf2eb9e5489
  1. Import vault configurations. Open terminal/gitbash in serve/vault directory and run following command
export VAULT_ADDR='http://127.0.0.1:8200' && ./init.sh 47d1d790-0cce-384f-5a28-3cf2eb9e5489
  1. Run ./gradlew clean build -x test in serve/ folder to generate jar files
  2. Start discoveryservice first as every service is dependent on it. Open a new terminal/console in serve folder and then run
java -jar discoveryservice/build/libs/discoveryservice-1.0.jar
  1. Start configservice second as most services are dependent on it for loading configurations. Open a new terminal/console in serve folder and then run
java -jar configservice/build/libs/configservice-1.0.jar
  1. Start edgeservice now as API calls go through edge service. Open a new terminal/console in serve folder and then run
java -jar edgeservice/build/libs/edgeservice-1.0.jar
  1. Start authservice next as all services are dependent on it for authentication. Open a new terminal/console in serve folder and then run
java -jar authservice/build/libs/authservice-1.0.jar
  1. Start rest of the services using the same command, each in a separate terminal/console
java -jar <path_to_service_jar_file>

NOTE: Each service can also be started by running <service>Application.main() using IDE

IMPORTANT: You can run ./gradlew :authservice:test to run AuthApplicationDataTest.initTestUserAndClientData(), this will add some users in db for testing purposes

Stopping microservices

  • Docker - Run following command docker-compose down

  • Local - Press ctrl + c in terminal/console to stop service

⚠️ **GitHub.com Fallback** ⚠️