【发布时间】:2020-04-30 15:20:22
【问题描述】:
Yocto 版本是战士。 我使用 GO/golang 用户应用程序(https-server)做了一个 yocto 项目,该应用程序在 raspi3 上运行良好。 现在我试图在 yocto 图像上自动启动它并且没有让它工作。 我知道有很多关于这方面的问题,但我没有找到有帮助的东西。 例如我试图按照这篇文章中的所有步骤 Enable systemd services using yocto 但它不会在 raspi 处自动启动。
我找到的服务的 raspi 中的这些文件:
/lib/systemd/system/https-server.service
/etc/systemd/system/multi-user.target.wants/https-server.service
如果我手动启动应用程序本身运行良好, 它位于 /usr/bin/https-server 的 raspi
我的构建/conf/local.conf:
IMAGE_INSTALL_append = " kernel-image kernel-devicetree sudo apt dnsmasq nano dhcpcd git glibc-utils localedef curl go https-server"
meta-https-server/
├── conf
│ └── layer.conf
└── recipes-https-server
└── https-server
├── files
│ ├── https-server.go
│ ├── https-server.service
│ ├── mytest
│ ├── server.crt
│ ├── server.key
│ └── testvideo.mp4
├── go-sw.inc
└── https-server.bb
https-server.bb
require go-sw.inc
inherit go systemd
#inherit go update-rc.d systemd
SRC_URI += "file://https-server.service"
SRC_URI += "file://https-server.go"
SYSTEMD_PACKAGES = "${PN}"
INITSCRIPT_PACKAGES = "${PN}"
SYSTEMD_SERVICE_${PN} = "https-server.service"
# Path
MY_KEY = "/data/yocto/2020-04-21-poky-warrior/poky-warrior/meta-https-server/recipes-https-server/https-server/files/server.key"
MY_CERT = "/data/yocto/2020-04-21-poky-warrior/poky-warrior/meta-https-server/recipes-https-server/https-server/files/server.crt"
TESTVIDEO = "/data/yocto/2020-04-21-poky-warrior/poky-warrior/meta-https-server/recipes-https-server/https-server/files/testvideo.mp4"
MY_TEST = "/data/yocto/2020-04-21-poky-warrior/poky-warrior/meta-https-server/recipes-https-server/https-server/files/mytest"
# COMPILER
do_compile() {
go build /data/yocto/2020-04-21-poky-warrior/poky-warrior/meta-https-server/recipes-https-server/https-server/files/https-server.go
}
# INSTALL
do_install() {
# install -d to create directories, "${D}/${bindir}" is /usr/bin
# systemd
install -d ${D}${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/https-server.service ${D}${systemd_unitdir}/system
# HTTPS certificate and key
install -d "${D}/${bindir}"
install -m 0755 "${MY_KEY}" "${D}/${bindir}"
install -m 0755 "${MY_CERT}" "${D}/${bindir}"
install -m 0777 "${TESTVIDEO}" "${D}/${bindir}"
install -m 0777 "${MY_TEST}" "${D}/${bindir}"
# HTTPS Server Software
install -m 0755 "${S}/build/https-server" "${D}/${bindir}"
}
FILES_${PN} += "${bindir}"
FILES_${PN} += "${libexecdir}"
FILES_${PN} += "${systemd_system_unitdir}"
REQUIRED_DISTRO_FEATURES= "systemd"
服务 https-server.service
[Unit]
Description=HTTPS Server sw startup script
[Service]
ExecStart=/usr/bin/https-server
[Install]
WantedBy=multi-user.target
【问题讨论】:
-
我不知道这与 Go 有什么关系,但让我们猜测一下。是否在您的问题中包含运行
systemctl status -l https-server(这是一个小的拉丁字母 L;ell)的输出? -
不要使用
/data/yocto/2020-04-21-poky-warrior/poky-warrior/meta-https-server/recipes-https-server/https-server/files/前缀,而是在SRC_URI中添加每个文件。您可以通过oe-pkgdata-util list-pkg-files -p https-server检查文件是否正确打包。如果变量设置正确,您可以使用bitbake -e https-server | egrep '^[A-Z][A-Z_]*'检查。并检查@kostix 命令。还有 SYSTEMD_AUTO_ENABLE 变量你可以检查,但它应该默认启用。 -
@kostix [我不知道这与 Go 有什么关系..] 你是对的,我删除了错误的标签,对此感到抱歉。
-
[注意包含运行“systemctl status -l https-server”的输出]命令 systemctl 没有在我的目标上运行,我尝试添加它并尝试。谢谢。