我想将参数传递给我正在启动的服务。例如,在调试模式下启动服务器。喜欢,
service jboss-as start debug
Run Code Online (Sandbox Code Playgroud)
或者这样的。但service
似乎不支持。
有什么办法吗?(对于 RHEL 6,如果这很重要。)
注意:这类似于Ubuntu/Linux:通常如何为启动脚本 (sysvinit) 定义启动参数?但不一样。
Lau*_*scu 10
在 RHEL 中,您有 /etc/sysconfig 文件夹。在此定义启动参数。在您的启动脚本中,您包括以下内容:
if [ -f /etc/sysconfig/$prog ] ; then
. /etc/sysconfig/$prog
fi
Run Code Online (Sandbox Code Playgroud)
检查现有服务以获取示例。
对于开发,您可以将启动参数放在导出的变量中(例如在 .bashrc 中),您可以随时手动覆盖该变量。
编辑
如果您真的想使用,service
还有其他一些选择。
您的脚本应至少支持start
和stop
。但是您也可以执行debug
命令。并开始您的程序:
service foo debug
Run Code Online (Sandbox Code Playgroud)
另一种方法是检查脚本中的第二个参数,然后使用以下命令启动程序:
service foo start debug
Run Code Online (Sandbox Code Playgroud)
将您的 init 脚本修改为:
case "$1" in
start)
if [ "$2" = "debug" ]
then
start_debug
else
start
fi
;;
Run Code Online (Sandbox Code Playgroud)
在 Ubuntu 中,启动参数通常位于:
/etc/default/<service_name>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
37515 次 |
最近记录: |