[systemd-devel] How to handle errors in systemd

shubham sharma newbie.shubham at gmail.com
Wed Apr 2 06:42:57 PDT 2014


Hi,

I have recently switched to RHEL7. I had earlier written a sample service
script "test_service.sh" in the /etc/init.d folder and i used the usual
method
$>/etc/init.d/test_service.sh start
to start the script and
$>/etc/init.d/test_service.sh stop
to stop the script.

the service script test_service.sh returns 0 on success and 1 in case it is
unable to stop the service due to some reason.

Now i wanted to use the systemd to start the service on RHEL7. For this, I
created the file test_service.service with the following details:

[Unit]
Description=test_service startup script
DefaultDependencies=no
Conflicts=shutdown.target

[Service]
Type=oneshot
ExecStart=/etc/init.d/test_service.sh start
TimeoutStartSec=0
ExecStop=/etc/init.d/test_service.sh stop
RemainAfterExit=yes
StandardOutput=syslog+console
StandardError=syslog+console
SyslogLevel=debug
SuccessExitStatus=1

The script test_service.service is running fine when the script
/etc/init.d/test_service returns 0. However in case the script
/etc/init.d/test_service returns 1, i am getting the following errors :

Apr 01 03:06:53 libl038 systemd[1]: test_service.service: control process
exited, code=exited status=1
Apr 01 03:06:56 libl038 systemd[1]: Stopped test_service startup script.
Apr 01 03:06:56 libl038 systemd[1]: Unit test_service.service entered
failed state.

and the high-level and low-level unit activation states from the systemctl
are failed.

Is there a way in which the return value from test_service.sh service
script can be handled by the systemd and it display a message that it is
unable to stop the test_service.service service?

Regards,
Shubham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20140402/e5eb597e/attachment.html>


More information about the systemd-devel mailing list