You can manage a Liferay server using Blade CLI. Managing a server with Blade CLI should be done in a Liferay Workspace.
Blade CLI has commands for installing, starting, stopping, inspecting, and modifying a Liferay server:
Make sure you’ve created a Liferay Workspace. See the Creating a Liferay Workspace article for more information.
Initialize a Liferay server by running
blade server init
This downloads the Liferay DXP bundle set in your workspace’s
gradle.propetiesfile. See the Adding a Liferay Bundle to Workspace article for more information.
You can initialize a server based on a defined environment by running the following command:
blade server init --environment [ENVIRONMENT]
For example, you could pass in the
uatvariable to generate a bundle with the configs set in the
Start your Liferay server (Tomcat or Wildfly/JBoss) by running
blade server start
This starts the server in the background. You can tail the logs by adding the
-tflag. If you prefer starting the server in the foreground, run
blade server run. Additionally, if you prefer starting the server in debug mode, add the
-dflag. See the Blade CLI article for additional flags you can set when starting your Liferay server.
Examine your server’s OSGi container by using Blade CLI’s
shcommand, which provides access to your server using the Felix Gogo shell. For example, to check if you successfully deployed your application from the previous section, you could run:
blade sh lb
Your output lists a long list of modules that are active/installed in your server’s OSGi container.
You can run any Gogo command using
blade sh. This command requires Developer Mode to be enabled. Developer Mode is enabled in workspace by default. See the Using the Felix Gogo Shell section for more information on this tool.
Once you’re finished modifying your Liferay bundle, you can package it as a sharable file by running this command:
blade gw distBundle[Zip|Tar]
This lets you create a ZIP or TAR file to share with others. This option is only available with Gradle at this time. The above command leverages Blade CLI’s
gwoption, which executes the project’s Gradle wrapper.
Turn off your Liferay server:
blade server stop
To reference all of Blade CLI’s available options, see the Blade CLI article.
Awesome! You learned how to interact with Liferay DXP using Blade CLI.