Systemd
為什麼服務不能在啟動時啟動
我想用來
systemd
在啟動時啟動服務。但是我收到消息說該服務處於非活動狀態(已死):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)
但我可以通過執行以下命令手動啟動它:
systemctl restart mdc_freespace_vldy_fusion_node.service
現在服務的狀態變為活動(執行):
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
這是我的服務文件:
[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
看看
journalctl -u mdc_freespace_vldy_fusion_node.service
。此服務以 0 退出。關於早期啟動狀態,有些東西是
/usr/bin/mdc/fusion/mdc_freespace_vldy_fusion_node
不喜歡的。