For example if I had two service files that ran as type=forking
that start two different java applications and then two service files that run as type=simple running different applications, is there a way to run another service file that would start/stop the other four but the other four can still be used independently?
for example:
dataingest-type1.service
dataingest-type2.service
different-dataingest.type3.service
different-dataingest.type4.service
All run properly as separate services under systemd.
Could a service, like dataingest.service
, start/stop the other four?
Also if one of the other services went down and the dataingest.service
was run again it should start the service again. (basically I tried making a script that runs systemctl start <list of services>
and set it up as a service, however if one of the services stops and the service start is run again it does not run the script as it thinks the service is running.)
So the dataingest.service
looked like this:
[Unit]
Description=Stuff blah blah
Requires=network.target
After=network.target
[Service]
Type=oneshot
ExecStart=/path/to/little/script.sh start
ExecStop=/path/to/little/script.sh stop
RemainAfterExit=true
[install]
WantedBy=multi-user.target
The bash script just does one job!
#/bin/bash
/bin/systemctl $1 dataingest-type1.service dataingest-type2.service different-dataingest.type3.service different-dataingest.type4.service
Obviously if there is a better method.....