[CentOS] CentOS 7 and systemd: SysV initscript: how detect boot vs. interactive use?

Mon Dec 19 14:31:26 UTC 2016
Jonathan Billings <billings at negate.org>

On Sun, Dec 18, 2016 at 08:50:54PM -0800, whitivery wrote:
> It is a system with several servers (various platforms/distros).
> 
> One piece of software runs on all of the servers.  For it to operate
> correctly, the instance on one server (prime) must start before the others
> (auxiliary).
> 
> So a boot delay is added (via a script sourced from initscript, which
> first waits for network to come up) to set the boot delay values for each
> server - prime at 0, others at some other value of 15 to 110 seconds
> depending on platform.
> 
> But when it is necessary to manipulate the service interactively via the
> "service" command, the boot delay needs to be bypassed.

Well, the first thing I'd do is make the service wait for the network
to be online.  In the [Unit] section add Wants=network-online.target.

Secondly, I'd try to find a way for the auxiliary services to ping the
prime service to ensure its up, and make that script a ExecStartPre
entry in the [Service] section.  You'll want to adjust the
TimeoutStartSec in case it might exceed the DefaultTimeoutStartSec in
/etc/systemd/system.conf, which is 90 seconds.

-- 
Jonathan Billings <billings at negate.org>