1

I have two services: mysql and liferay. Liferay start depends on mysql but liferay's shutdwon also depends on mysql. The problem is that systemd will shutdown mysql before liferay's shutdown is over. When I run "systemctl stop mysql" it will start shutting down both services at the same time and liferay will have no mysql service to finish it's own shutdown.

I have Liferay's service declared like this:

[Unit]
Description=Liferay Portal
After=network.target,mysql.service
Requires=mysql.service

[Service]
Type=forking
WorkingDirectory=/opt/liferay
ExecStart=/opt/liferay/liferay-ce-portal/tomcat/bin/startup.sh
User=liferay
Group=liferay
Restart=always

[Install]
WantedBy=multi-user.target

Any ideas?

TIA

Fernando

ferdez
  • 41
  • 4
  • 1
    According to [this quote from the docs](https://serverfault.com/questions/785127/how-to-stop-systemd-services-in-specific-order) `After=` should do the trick. I'd try removing the `Requires=` directive, it may override the `After=` behavior. – Gerald Schneider Feb 22 '23 at 09:51

1 Answers1

0

As per Gerald's comment, it seems the answer is simply to remove the "Requires=".

This version does the trick:

[Unit]
Description=Liferay Portal
After=mysql.service

[Service]
Type=forking
WorkingDirectory=/opt/liferay
ExecStart=/opt/liferay/liferay-ce-portal/tomcat/bin/startup.sh
User=liferay
Group=liferay
Restart=always

[Install]
WantedBy=multi-user.target

Thanks Gerald!

ferdez
  • 41
  • 4