我有一个 systemd 服务,它检查启动时是否安装了外部媒体。
\n[Unit]\nDescription=My App\nConditionPathIsMountPoint=/mnt/sdcard\n\n[Service]\nWorkingDirectory=/opt/myapp\nExecStartPre=+/opt/myapp/bin/pre.sh\nExecStart=/opt/myapp/bin/myapp\nExecStop=/bin/kill -INT ${MAINPID}\nExecReload=/bin/kill -INT ${MAINPID} && /opt/myapp/bin/myapp\nRestart=always\nRestartSec=5\nUser=user\nGroup=user\n\n[Install]\nWantedBy=multi-user.target mnt-sdcard.mount\nRun Code Online (Sandbox Code Playgroud)\n我想等待myapp启动,直到/mnt/sdcard安装完毕。\n但此服务运行不佳。当安装介质被延迟时,systemd 会抛出异常start condition failed并且不会重试。
# systemctl status myapp\n\xe2\x97\x8f myapp.service - My App\n Loaded: loaded (/etc/systemd/system/myapp.service; enabled; vendor preset: enabled)\n Active: inactive (dead)\nCondition: start condition failed at Wed 2021-01-27 14:22:31 JST; 2h 35min ago\n ConditionPathIsMountPoint=/mnt/sdcard was not met\nRun Code Online (Sandbox Code Playgroud)\n当启动条件失败时如何重试启动?
\n