Saturday, February 29, 2020

Useful Apache Gogo Shell Commands in Liferay 7.2/DXP


Apache Gogo Shell is command line interface (CLI) to interact with OSGi module framework or OSGi container.

Apache Gogo shell is very useful in trouble shooting of module issues, getting module information and perform certain action like install, active and de-active OSGi bundles.

Liferay is already using Apache Gogo Shell and when we start Liferay 7.2/DXP portal, it will start automatically and we can use different ways to access Apache Gogo Shell in Liferay Portal Environment.


We can categorize Gogo shell commands in the following types.

Basic Commands
Declarative Services (DS) | Service Component Registry Commands (SCR) Commands
Dependency Management (DM) Commands

Basic Commands

Its regular usage commands to get bundles/module information like list bundles and its status.
Following are list of useful basic commands.


lb
lb | grep <BUNDLE_MATCH_PATTERN>
bundle <BUNDLE_ID>
headers <BUNDLE_ID>
install [URI_JAR_FILE_PATH]
start [BUNDLE_ID]
stop [BUNDLE_ID]
uninstall [BUNDLE_ID]
inspect requirement service [BUNDLE_ID]
inspect capability service [BUNDLE_ID]
diag [BUNDLE_ID]
upgrade:check
system:check
history
help

Example Usage


lb
lb | grep student
bundle 1076
headers 1076
install "file:C://Liferay/Liferay7.2/student-web/target/student-web-1.0.0.jar"
start 1076
stop 1076
uninstall 1076
inspect requirement service 1076
inspect capability service 1076
diag 1076
upgrade:check
system:check
history
help


Identify Bundle ID

Use lb command in the Gogo shell it will display the list of bundles installed in the OSGi modules framework. In the console view first column represent the BUNDLE ID.

Example


Declarative Services (DS) | Service Component Registry Commands (SCR)

Liferay module framework uses the OSGi Declarative Services/Service Component Registry to manage module components and its services references. Gogo shell leverage the Service Component Registry and Declarative Services. We can access services information using Gogo shell commands. 
In Liferay 7.2/DXP most of modules are using DS/SCR framework. Only service builder components are using the Apache Felix Dependency Management Framework to register and manage service components.

If you see any @Component or @Reference annotations in the java class, it implies that module components are using the Declarative Services/Service Component Registry Framework.

The following are some of useful Gogo Shell commands to insect components and its references.

services
services grep [SEARCH-PATTERN]
ds:unsatisfied
ds:unsatisfied [BUNDLE_ID]
scr:info [COMPONENT_ID]
scr:list
scr:list | grep [SEARCH-PATTERN]


Example Usage


services
services | grep student
ds:unsatisfied
ds:unsatisfied 1075
scr:info 4884
scr:list
scr:list | grep student


Identify COMPONENT ID

Use services/ ds:unsatisfied go shell commands and it will display component information and its ID.

Example 1


Example 2


Dependency Management (DM) Commands

Liferay Service Builder is using Apache Felix Dependency Management framework to manage components and its dependencies. Apache Gogo Shell leverage the Dependency Management framework and have set of predefined commands to provide more details of service components.
These commands are very useful when we trouble shoot about unsatisfied services in the registry.

The following are some of useful Gogo Shell commands related to Dependency Management

dm
dm | grep [SEARCH-PATTERN]
dm cp
dm nd
dm na
dm wtf


OR

dm
dm | grep [SEARCH-PATTERN]
dm compact
dm nodeps
dm notavail
dm wtf

Example Usage

dm
dm | grep student
dm cp
dm nd
dm na
dm wtf


Example usage screen



Reference


Author


0 comments :

Post a Comment

Recent Posts

Recent Posts Widget

Popular Posts