How to: Restart the Deploy service automatically

Question

Is it possible to configure the xlr-wrapper.conf to restart the service after a few minutes when we trigger the server/shutdown endpoint? Setting it by the recovery settings on the Windows service have haven't been successful.

Answer

You can configure the Java Service Wrapper to behave differently based on the exit code generated when the JVM process shuts down.
 
We ran some tests on Windows where Release is set up to run as a service. For testing, We used the following API command to shut down the Release service:

curl -X POST --basic -u admin:admin http://localhost:5516/server/shutdown -H "Cookie: XSRF-TOKEN=1;"
-H "X-XSRF-TOKEN:1"

Because this command initiates a graceful shutdown, the exit code returned was 0.

To handle this, we added the following configuration in xlr-wrapper-win.conf:

wrapper.on_exit.0=RESTART
wrapper.on_exit.default=RESTART

After reinstalling the Release service, we verified the setup. When the service was up and running, We issued the API shutdown command again, and, as expected, the service restarted automatically due to the exit code 0.

Log snippet:

FINEST|8256/0|Service XL Release Server|24-11-07 09:09:58|2024-11-07 09:09:58.195 [Thread-37] {}
INFO c.x.x.r.j.impl.ReportExecutorService - Shut down thread pool 'report'
FINEST|8256/0|Service XL Release Server|24-11-07 09:09:58|2024-11-07 09:09:58.308 [Thread-37] {}
INFO c.x.x.actors.ReleaseActorService - Shutting down Release actor service
FINEST|8256/0|Service XL Release Server|24-11-07 09:09:58|2024-11-07 09:09:58.308 [Thread-37] {}
INFO j.util.concurrent.ExecutorService - Shutting down timeout executor
FINEST|8256/0|Service XL Release Server|24-11-07 09:09:58|2024-11-07 09:09:58.387 [Thread-37] {}
INFO c.x.x.events.XLReleaseEventBus - Shutting down Release event bus
INFO|wrapper|Service XL Release Server|24-11-07 09:09:59|restart internal RUNNING controller killed
restart handler
INFO|wrapper|Service XL Release Server|24-11-07 09:09:59|stopping process with pid/timeout 8256 45000
INFO|wrapper|Service XL Release Server|24-11-07 09:09:59|process exit code: 0
INFO|wrapper|Service XL Release Server|24-11-07 09:10:05|started process with pid 5844
INFO|5844/1|Service XL Release Server|24-11-07 09:10:09|2024-11-07 09:10:08.969 [main] {} INFO
c.xebialabs.xlrelease.ReleaseServer - Digital.ai Release version 24.1.10 (built at 24-10-03
10:32:45)
INFO|5844/1|Service XL Release Server|24-11-07 09:10:09|2024-11-07 09:10:08.988 [main] {} INFO
c.xebialabs.xlrelease.ReleaseServer - Digital.ai Release running with OpenJDK Runtime Environment
(version 17.0.12+7) from Eclipse Adoptium
INFO|5844/1|Service XL Release Server|24-11-07 09:10:09|2024-11-07 09:10:08.988 [main] {} INFO
c.xebialabs.xlrelease.ReleaseServer - (c) 2012-2024 Digital.ai.
INFO|5844/1|Service XL Release Server|24-11-07 09:10:13|2024-11-07 09:10:13.150 [main] {} INFO
c.x.xlrelease.XLReleaseBootstrapper$ - Attempting plugin synchronization

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.