0

This is related to another question about system properties. In that question, I make the offhand comment:

It seems to me you'd need to send a UNIX signal (SIGINT maybe?) to Open Liberty to cause it to restart.

I am breaking this comment out into its own top-level question, which I will more formally state now.

I have a customer running Liberty on Kubernetes (Azure Kuberenetes service). They would like to have a technique that has the same effect as when you are running liberty:dev from the liberty-maven-plugin and one of the changes listed in Detect, recompile, and deploy code changes happens. They would like this technique to be arbitrarily triggerable at a time of their choosing. Currently they are implementing this with a kubernetes pod restart, but they want something less obtrusive.

edburns
  • 482
  • 1
  • 4
  • 13

1 Answers1

0

If they just want to restart an application at an arbitrary time without restarting the pod, the best way would probably be to use the ApplicationMBean. They would need to enable the restConnector-2.0 feature and expose the port. They would also need to configure application updates using the following in server.xml:

<applicationMonitor updateTrigger="mbean"/>

This will disable dynamic updates of the application unless they explicitly invoke the restart() method on the mbean.

This would not be the recommended approach -- generally in a kubernetes environment you would want to replace the existing pod. But, this will work if they need it.

If they want to restart the entire server, they could exec into the pod and use the server script to stop and start the server. Again, this would not be a recommended approach.

Brent Daniel
  • 355
  • 1
  • 4
  • The exec strategy won't work without building a custom image ahead of time that uses a different command as the container's CMD directive. Stopping the server at all in the default images would stop the container/pod. – lwestby Sep 14 '22 at 18:16
  • @lwestby The suggested solution wouldn't cause the server to stop, it would have them restart just the application so it wouldn't require a custom image. – Alasdair Sep 14 '22 at 18:32
  • That's true (in relation to my second suggestion of using 'exec').. It would only work with a custom image. – Brent Daniel Sep 14 '22 at 20:27
  • @BrentDaniel I don't know why I didn't realize that is what lwesby was referring to when I added my comment. – Alasdair Sep 15 '22 at 01:00
  • Yeah I mean to add that the mbean strategy will work due to only restarting the app, not the whole server. – lwestby Sep 15 '22 at 14:18