Hi all, I am doing some tests with a CentOS7 vm image before to enter in our production environment. I need to migrate some sysvinit scripts to systemctl. In all of them I need to launch some daemons in the same init script. For example: a) start daemon1 b) if daemon1 returns no startup errors, launch daemon2 c) if daemon1 returns any startup error, doesn't start daemon2 and exit. Is it possible to do this with systemctl?? Thanks.
On 1 Sep 2014 11:10, "C. L. Martinez" <carlopmart at gmail.com> wrote:> > For example: > > a) start daemon1 > b) if daemon1 returns no startup errors, launch daemon2 > c) if daemon1 returns any startup error, doesn't start daemon2 and exit. > > Is it possible to do this with systemctl??In this specific example I'd probably do it as two service units with daemon2 wanted by multi-user.target and requiring the daemon1 service... That was daemon2 will want to be started by default and dependencies mean that will start daemon1 in the process of doing so... But since 2 requires 1 if 1 fails to start for some reason then 2 won't be stated.
On Mon, 2014-09-01 at 10:10 +0000, C. L. Martinez wrote:> Hi all, > > I am doing some tests with a CentOS7 vm image before to enter in our > production environment. I need to migrate some sysvinit scripts to > systemctl. > > In all of them I need to launch some daemons in the same init script. > For example: > > a) start daemon1 > b) if daemon1 returns no startup errors, launch daemon2 > c) if daemon1 returns any startup error, doesn't start daemon2 and exit. > > Is it possible to do this with systemctl?? > > Thanks.Could this help? http://www.freedesktop.org/software/systemd/man/systemd.service.html ExecStartPre=, ExecStartPost Additional commands that are executed before or after the command in ExecStart=, respectively. Syntax is the same as for ExecStart=, except that multiple command lines are allowed and the commands are executed one after the other, serially. If any of those commands (not prefixed with "-") fail, the rest are not executed and the unit is considered failed. -- Darod Zyree <darodzyree at gmail.com>