-1

I have set up an application running in 2 servers:

  • Server 1 contains the main Administration module
  • Server 2 contains additional modules that need to start up after the Admin module is up and running

and have created the systemd files to start up things automatically after a reboot.

So server 1 has something like:

admin.service

[Unit]
Description=Start Admin

[Service]
Type=simple
ExecStart=/home/usr/startup/startAdmin.sh
ExecStop=/home/usr/startup/stopAdmin.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

and server 2 has something like:

other.service

[Unit]
Description=Start Others

[Service]
Type=simple
ExecStart=/home/usr/startup/startOther.sh
ExecStop=/home/usr/startup/stopOther.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

What can be implemented to ensure other.service (in server 2) only kicks off if admin.service has started?

Beto
  • 132
  • 2
  • 12

1 Answers1

1

In other.service you can add a ExecStartPre ( man systemd.service ). The syntax is the same as ExecStart.

or other.service can have a dependency to a check service check.service

In both the command will be similar to :

while ( ! nc -w2 -z <ADMINIP> <ADMINPORT> >/dev/null 2>&1 ) ; do sleep 2 ; done
EchoMike444
  • 1,513
  • 1
  • 9
  • 8