1

I want to use systemd to make a service startup at boot. However I get the message saying that the service is inactive(dead):

root@mdchost:/lib/systemd/system# systemctl status mdc_freespace_vldy_fusion_node.service
● mdc_freespace_vldy_fusion_node.service - MDC Freespace Vldy Fusion Node
   Loaded: loaded (/lib/systemd/system/mdc_freespace_vldy_fusion_node.service; enabled; vendor preset:
   Active: inactive (dead) since Sat 2018-08-04 01:06:48 BST; 5min ago
  Process: 3841 ExecStartPost=/bin/bash /usr/bin/mdc/base/set_limit.sh FUSI mdc_freespace_vldy_fusion_
  Process: 3838 ExecStart=/usr/bin/mdc/fusion/mdc_freespace_vldy_fusion_node (code=exited, status=0/SU
  Process: 3090 ExecStartPre=/opt/x86/ros/kinetic/bin/rosparam load /etc/mdc/fusion/kinematics_dynamic
  Process: 2266 ExecStartPre=/opt/x86/ros/kinetic/bin/rosparam load /etc/mdc/fusion/freespace_vldy_fus
 Main PID: 3838 (code=exited, status=0/SUCCESS)

But I can make it startup manually by executing the command:

systemctl restart mdc_freespace_vldy_fusion_node.service

And now the status of the service becomes active(running):

root@mdchost:/lib/systemd/system# systemctl status mdc_freespace_vldy_fusion_node.service
● mdc_freespace_vldy_fusion_node.service - MDC Freespace Vldy Fusion Node
   Loaded: loaded (/lib/systemd/system/mdc_freespace_vldy_fusion_node.service; enabled; vendor preset:
   Active: active (running) since Sat 2018-08-04 01:29:31 BST; 1s ago
  Process: 2065 ExecStartPost=/bin/bash /usr/bin/mdc/base/set_limit.sh FUSI mdc_freespace_vldy_fusion_
  Process: 2017 ExecStartPre=/opt/x86/ros/kinetic/bin/rosparam load /etc/mdc/fusion/kinematics_dynamic
  Process: 1991 ExecStartPre=/opt/x86/ros/kinetic/bin/rosparam load /etc/mdc/fusion/freespace_vldy_fus
 Main PID: 2063 (mdc_freespace_v)
    Tasks: 6
   Memory: 3.5M
      CPU: 469ms
   CGroup: /system.slice/mdc_freespace_vldy_fusion_node.service
           └─2063 /usr/bin/mdc/fusion/mdc_freespace_vldy_fusion_node

Here is my service file:

[Unit]
Description=My Node
Requires=start_roscore.service
After=start_roscore.service

[Service]
User=mdc
Group=mdc

Type=simple
KillMode=proces
Restart=on-failure
RestartSec=16
StartLimitInterval=0

EnvironmentFile=/usr/bin/mdc/base/env.cfg
EnvironmentFile=/usr/bin/mdc/ros/ros.cfg

ExecStartPre=/opt/x86/ros/kinetic/bin/rosparam load /etc/mdc/fusion/freespace_vldy_fusion_config.yaml
ExecStartPre=/opt/x86/ros/kinetic/bin/rosparam load /etc/mdc/fusion/kinematics_dynamics.yaml

ExecStart=/usr/bin/mdc/fusion/mdc_freespace_vldy_fusion_node
ExecReload=/usr/bin/mdc/fusion/mdc_freespace_vldy_fusion_node

ExecStartPost=/bin/bash /usr/bin/mdc/base/set_limit.sh FUSI mdc_freespace_vldy_fusion_node
1

Take a look at journalctl -u mdc_freespace_vldy_fusion_node.service.

This service exited with 0. There is something about the early boot state the /usr/bin/mdc/fusion/mdc_freespace_vldy_fusion_node didn't like.

  • Great, let me see. – Yves Nov 27 '18 at 8:43
  • At boot time, systemd is probably doing the equivalent of systemctl start start_roscore.service && systemctl start mdc_freespace_vldy_fusion_node.service, i.e. starting both services in sequence as fast as possible. If start_roscore.service needs a bit more time to set things up after it has nominally started up before it can actually service requests, your service's start-up might be failing because the core is not quite ready yet. The core might need just a few more seconds to become ready, but in computer timescales, much can happen in that time. – telcoM Nov 27 '18 at 8:47
  • Care to provide more detail as to what you saw in the journal? Did you manage to work around it? Was @telcoM right? – danblack Nov 28 '18 at 2:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.