c - 为什么我的进程没有在启动时启动?(OpenWrt)
问题描述
我定义了以下脚本(称为 pcap):
#!/bin/sh /etc/rc.common
# Example script
# Copyright (C) 2007 OpenWrt.org
START=10
STOP=15
start() {
echo start
./delete_pcap
# commands to launch application
}
stop() {
echo stop
# commands to kill application
}
我将此脚本放在 /etc/init.d 文件夹中。当我这样做时/etc/init.d/pcap start
,将执行启动函数并正确执行 delete_pcap(C 语言,位于同一/etc/init.d
文件夹中)程序。无论如何,如果我这样做/etc/init.d/pcap enable
了,那应该在每次重新启动时执行 delete_pcap 程序,系统启动时程序不会启动。我签入了文件夹/etc/rc.d
并且我有S10pcap
文件(在我启用时创建)。那么,问题出在哪里?
delete_pcap
为什么在系统启动时不执行?
解决方案
尝试使用新的服务管理工具,例如 procd:
https://openwrt.org/docs/guide-developer/procd-init-scripts
您的应用的示例
#!/bin/sh /etc/rc.common
APP=/usr/bin/pcap # specify the full path this is example
USE_PROCD=1
START=98 # indicates that process should start last
STOP=99
start_service() { # Override this to start your app
procd_open_instance
procd_set_param command "$APP"
procd_close_instance
}
无需覆盖其他功能,如停止启动重启
推荐阅读
- excel - 设置一个独立于执行模块的常量
- javascript - 如何使 SpeechRecognition 和 SpeechSynthesis API 一起工作?
- android - 如何在拦截器的回调中获取对象类型分配
- html - ASP.NET Core - 为 SPA 提供不同的 HTML 文件?
- python-3.x - 执行snakemake规则作为最后一条规则
- node.js - 错误 [ERR_STREAM_CANNOT_PIPE]:无法管道,无法读取 nodejs
- c++ - 将可变参数从一个函数传递到另一个函数
- firebase - Firebase 只允许云函数访问读写
- android - 你如何 adb 到多实例 bluestacks 4?辅助实例的 adb-port 是什么?
- angular - 为什么 CKEditor 4 Angular 模块表单字段验证不起作用?