The scenario is that I have a CentOS v7.0 system that can have up to four instances of JIRA running, the instances are Production, Staging, Development and BETA.
When I start the system I want all four of the service instances to start in a staggered fashion 100 seconds apart (each JIRA instance takes about 80 seconds to start). I was able to solve the staggered start by using systemd timers (which are certainly a lot more elegant than the shell code I was using in SysV inits). Each service runs in its own slice and has an appropriate QOS level set via the slice controls. It all runs very nicely.
The problem I'm having is that when I issue a halt/shutdown/reboot only the jira_*.timer instances are being called by the systemd shutdown script and the JIRA instances are not being shutdown correctly.
How can I get the ExecStop action in the jira_*.service units to fire during a shutdown/reboot?
PRD = 5sec delay
STG = 100sec delay
DEV = 200sec delay
EAP = 300sec delay
/usr/lib/systemd/system/jira_stg.service
[Unit]
Description=Atlassian JIRA Staging instance
Documentation=https://confluence.atlassian.com/display/JIRA/JIRA+Documentation
After=mysql.service nginx.service
Requires=mysql.service nginx.service
Before=shutdown.target reboot.target halt.target
[Service]
Type=forking
ExecStart=/jira/stg/catalina.home/bin/startup.sh
ExecStop=/jira/stg/catalina.home/bin/shutdown.sh 60
TimeoutSec=300
User=ujirastg
Group=gjirastg
Slice=jira_stg.slice
CPUAccounting=true
CPUShares=600
MemoryAccounting=true
MemoryLimit=1200M
BlockIOAccounting=true
BlockIOWeight=200
[Install]
WantedBy=multi-user.target
/usr/lib/systemd/system/jira_stg.timer
[Unit]
Description=Atlassian JIRA Staging instance service startup after delay
[Timer]
# Time to wait after systemd starts before we start the service
OnStartupSec=100s
AccuracySec=5s
Unit=jira_stg.service
[Install]
WantedBy=multi-user.target
I'm only enabling the jira_* .timer units as I found that if I enabled the jira_* .service units that the timers were ignored and everything tried to start at once.
systemctl enable jira_eap.timer
systemctl enable jira_dev.timer
systemctl enable jira_stg.timer
systemctl enable jira_prd.timer
From journalctl, showing the timers being fired during a reboot.
jira systemd[1]: Stopping Flexible branding.
jira systemd[1]: Stopped Flexible branding.
jira systemd[1]: Stopping Timers.
jira systemd[1]: Stopped target Timers.
jira systemd[1]: Stopping Atlassian JIRA Early Access Program instance service startup after delay.
jira systemd[1]: Stopped Atlassian JIRA Early Access Program instance service startup after delay.
jira systemd[1]: Stopping Atlassian JIRA Development instance service startup after delay.
jira systemd[1]: Stopped Atlassian JIRA Development instance service startup after delay.
jira systemd[1]: Stopping Atlassian JIRA Staging instance service startup after delay.
jira systemd[1]: Stopped Atlassian JIRA Staging instance service startup after delay.
jira systemd[1]: Stopping Daily Cleanup of Temporary Directories.
jira systemd[1]: Stopped Daily Cleanup of Temporary Directories.
jira systemd[1]: Stopping Atlassian JIRA Production instance service startup after delay.
jira systemd[1]: Stopped Atlassian JIRA Production instance service startup after delay.
jira systemd[1]: Stopping Sockets.
jira systemd[1]: Stopped target Sockets.