I am having a service that depends on Cassandra coming up gracefully and the cluster being up and ready.
To ensure that the dependency order is met, I have the following unit file
[Unit]
Requires=cassandra.service
After=cassandra.service
[Service]
Environment=JAVA_HOME=/usr/java/jre
[email protected]@/webapps/bringup-app/bin/bringup
TimeoutStartSec=0
ExecStop=
[email protected]@/logs/bringup.pid
Restart=always
[Install]
WantedBy=multi-user.target
How do I ensure that the bringup-app process waits for 30 seconds before it attempts to start up? Currently although it is started after Cassandra, I have noticed that the Cassandra cluster is not up yet and hence any attempt from the bringup-app to connect to Cassandra as part of startup fails.
I therefore want to add a delay. Is that possible via the unit file?
ExecStop=kill -TERM $MAINPID
andExecStop=timeout 15 tail --pid=$MAINPID -f /dev/null
. The first line sends SIGTERM signal to JVM so it requests it to exit. The second line waits the process to actually stop but no longer than 15 seconds (so waiting with time limit).