使用自定义系统服务在启动时执行珊瑚板演示模型

问题描述 投票:0回答:1

我正在尝试将我的珊瑚板配置为使用自定义systemd服务引导至Coco对象检测模型。我创建了可执行文件,单位文件,然后启用了该服务。目的是使摄像机源显示在监视器上,但是当我打开开发板电源时,监视器仅显示蓝色背景(我假定开发板的“主屏幕”)。

可执行文件:

edgetpu_detect \
--model mobilenet_ssd...
--labels coco...

单位文件:

[Unit]
Description=systemd service.
After=weston.target

[Service]
PAMName=login
Type=simple
User=mendel
WorkingDirectory=/home/mendel
ExecStart=/bin/bash /usr/bin/test_service.sh
Restart=always

[Install]
WantedBy=multi-user.targer

启用后和开机后的服务状态:>]]

mendel@jumbo-tang:/etc/system$ sudo systemctl status myservice.service
myservice.service - systemd service.
    Loaded: loaded (/etc/systemd/system/system/myservice.service; enabled; vendor preset
    Active: active (running) since Mon 2020-01-06 03:32:03 UTC; 1s ago
Main PID: 4847 (bash)
     Tasks: 0 (limit: 4915)
    CGroup: /system.slice/myservice.service
            4847 /bin/bash /usr/bin/test_service.sh
Jan 06 03:32:03 jumbo-tang systemd[1]: myservice.service: Service hold-off time
Jan 06 03:32:03 jumbo-tang systemd[1]: Stopped Example systemd service..
Jan 06 03:32:03 jumbo-tang systemd[1]: Started Example systemd service..
Jan 06 03:32:03 jumbo-tang systemd[4847]: pam_unix(login:session): session opene

可执行文件已保存到/usr/bin,并已通过sudo chmod +x /usr/bin/test_service.sh设置为可执行文件>

单位文件已保存到/etc/systemd/system,并被授予sudo chmod 644 /etc/systemd/system/myservice.service的权限

我很好奇,我的可执行文件是否不能简单地包含我通常用来启动模型的代码(如我所做的那样,或者是否正确配置了我的单位文件,或者我可能会出错)没想到。

感谢您的任何帮助!

我正在尝试将我的珊瑚板配置为使用自定义systemd服务引导至Coco对象检测模型。我创建了可执行文件,单位文件,然后启用了该服务。目的...

[我相信我已经通过珊瑚的支持回答了您,我们讨论过您很可能只是缺少了几件事:

1)特别是在启动时启动systemd服务时,有时并非所有环境变量都已加载,在这种情况下,您可能需要添加以下行:

Environment=DISPLAY=:0

在ExecStart之前。但是,我不怀疑这是问题所在,因为该进程确实在weston.target上等待,而weston.target应该已经在环境变量上等待。

2)这一个比前一个复杂得多,但您拼错了

"target" in "WantedBy=multi-user.targer" (joking, of course)

我在这里再次显示这些步骤,以作为将来参考的示例。

1)创建一个具有以下内容的文件调用detects.service:

[Unit]
Description=systemd auto face detection service
After=weston.target

[Service]
PAMName=login
Type=simple
User=mendel
WorkingDirectory=/home/mendel
Environment=DISPLAY=:0
ExecStart=/bin/bash /usr/bin/detect_service.sh
Restart=always

[Install]
WantedBy=multi-user.target

2)mv文件/lib/systemd/system/detects.service

$ sudo mv detects.service /lib/systemd/system/detects.service

3)创建一个具有以下内容的文件调用detect_service.sh

edgetpu_detect --model fullpath/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite --label fullpath/coco_labels.txt

4)使它可执行并MV到/ usr / bin

$ sudo chmod u+x detect_service.sh
$ sudo mv detect_service.sh /usr/bin

5)通过systemctl启用服务>

$ sudo systemctl enable detects.service
systemd google-coral
1个回答
0
投票

[我相信我已经通过珊瑚的支持回答了您,我们讨论过您很可能只是缺少了几件事:

© www.soinside.com 2019 - 2024. All rights reserved.