Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force WebSphere Liberty to start WARs in certain order

Do you know how to force WebSphere Liberty to start WARs (deployed separetly or within single EAR file) in given order. By default WLP is starting it in parallel and there is no information how to tweak it up.

I know that in full WebSphere Application server there was/is such option to define starting weight in deployment.xml but in WLP it seems to be missing.

like image 356
e1m7bo Avatar asked Oct 20 '25 09:10

e1m7bo


2 Answers

This is now possible in Liberty as of version 20.0.0.4 (though it will be in beta until at least 20.0.0.6).

To start "app1" before "app2", you would specify the "startAfter" attribute on "app2".

<application id="app1" location="start_me_first.war"/>
<application id="app2" location="start_me_later.war" startAfter="app1"/>

The startAfter attribute takes a list of application IDs, so you can specify more than one application that must be started before that application can start.

like image 126
Brent Daniel Avatar answered Oct 22 '25 04:10

Brent Daniel


At the moment, there is no out-of-the-box way to control application start order in Liberty.

A few alternate options may be:

1) Use 1 app per server

Split apart the server so you only have 1 app per server, then use a container orchestration layer to mandate an ordering at the server level.

2) Use dropins + shell script

Use the ${server.config.dir}/dropins/ folder and move applications into that folder in a controlled order using scripting. For example:

mv firstApp.war /path/to/server/dropins/
# wait some amount of time as a heuristic
sleep 5
mv nextApp.war /path/to/server/dropins/

3) Use autoStart=false and start with ApplicationMBean

If you set <application autoStart="false"> on your applications, you can control the start ordering by invoking ApplicationMBean.start() via JMX. See the ApplicationMBean doc as well as Working with JMX MBeans on Liberty.


This request has come up a few times though, so we've opened this github issue to discuss a built-in solution.

like image 24
Andy Guibert Avatar answered Oct 22 '25 03:10

Andy Guibert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!