LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub

Deploy Service2

In the previous step, we have tested the service2 to make sure that it is working for the tests in the development project. In this step, we are going to build the jar file and deploy it to the server instance along with service1.

cd ~/networknt/light-example-4j/hybrid/hello-world/service2
./mvnw install

Once the build is done, you should have service2-1.0.0.jar in the target folder. We deploy the service1 by adding it to the classpath when starting the server instance, it works if you have one or two services, but if you have too many services or plan to add more services in the future, it is easier just to copy all services to a folder and put that folder as part of server classpath.

Let’s create a folder in the /tmp and name it service after that copy the two jar files from service1 and service2 to this newly created folder.

cd /tmp
mkdir service
cd service
cp ~/networknt/light-example-4j/hybrid/hello-world/service1/target/service1-1.0.0.jar .
cp ~/networknt/light-example-4j/hybrid/hello-world/service2/target/service2-1.0.0.jar .

With the two files in the service folder, let’s start the server with the following command to load services from the service folder.

cd ~/networknt/light-example-4j/hybrid/hello-world/server/target
java -cp hello-1.0.0.jar:/tmp/service/* com.networknt.server.Server

For the server console, you can see the following that indicates four handlers are loaded.

RpcStartupHookProvider: handlers size 4
RpcStartupHookProvider add id lightapi.net/service2/command/0.1.1 map to com.networknt.hello.handler.CommandNew
RpcStartupHookProvider add id lightapi.net/service2/command/0.1.0 map to com.networknt.hello.handler.CommandOld
RpcStartupHookProvider add id lightapi.net/service1/info/0.1.0 map to com.networknt.hello.handler.Info
RpcStartupHookProvider add id lightapi.net/service1/query/0.1.0 map to com.networknt.hello.handler.Query

You can test the service1 and service2 with the following commands.

curl -k -X POST https://localhost:8443/api/json -d '{"host":"lightapi.net","service":"service1","action":"query","version":"0.1.0","data":{"param1":"value1","param2":"value2"}}'

curl -k -X POST https://localhost:8443/api/json -d '{"host":"lightapi.net","service":"service2","action":"command","version":"0.1.0","data":{"source":"value1","target":"value2"}}'

curl -k -X POST https://localhost:8443/api/json -d '{"host":"lightapi.net","service":"service2","action":"command","version":"0.1.1","data":{"source":"value1","target":"value2"}}'

As you can see, two services are merged together and served by the same server instance. You can, later on, develop other services and put them into the same service folder and restart the server instance to load them.

There are also other options that will be explained in the summary section.

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Deploy Service2” was last updated: April 6, 2019: fixes #66 add hello world tutorial for light-hybrid-4j (42ad462)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute