Your question contains of two separate issues: (a) how to translate services dependency to systemd unit files syntax and (b) how to change unit definitions without changing unit files provided by software vendor.
As for (a), you correctly note that you want After=
keyword. JBoss unit file should contain both After=<WebSphereMQ unit name>
and Wants=<WebSphereMQ unit name>
. Reason for that is: functional dependencies between units and order of units start are separate variables/dimensions. Sometimes you want service A to start every time when service B starts, and that's what Wants=
and Requires=
are for. Sometimes you want service A to start after service B, if service B is in queue already; that's what After=
and Before=
are for. Usually you want both of them.
As for (b), you need to use feature called "drop-ins". They are available in systemd since pretty much beginning, but documentation was scattered across many man pages and hard to find. This changed in one of more recent versions (219, I believe), when detailed description was added near end of man systemd.unit.
Drop-ins are small configuration bits that override parts of existing unit definition. Their goal is to allow system administrator to make local changes without having to overwrite unit file provided by software vendor (therefore software updates are a little easier, as you don't have to worry about package manager overwriting your changes).
Drop-ins are text files with names ending with .conf
and are placed in <unit name>.d
directory.
In your case, you want to create directory /etc/systemd/system/jboss.service.d/
(assuming JBoss comes with jboss.service
unit file) and then create file webspheremq.conf
with following content:
[Unit]
Wants=WebSphereMQ
After=WebSphereMQ
After reloading systemd configuration (systemctl daemon-reload
) you should see changes in systemctl show jboss.service
and systemctl status jboss.service
. Here is what you can expect from second command (note "Drop-In" line):
● rsnapshot@monthly.service - rsnapshot monthly backup
Loaded: loaded (/etc/systemd/system/rsnapshot@.service; static)
Drop-In: /etc/systemd/system/rsnapshot@monthly.service.d
└─after.conf
Active: inactive (dead)