我正在尝试为 redhat linux 上的进程设置一个初始化脚本:
#!/bin/sh
#
# Startup script for Conquest
#
# chkconfig: 345 85 15 - start or stop process definition within the boot process
# description: Conquest DICOM Server
# processname: conquest
# pidfile: /var/run/conquest.pid
# Source function library. This creates the operating environment for the process to be started
. /etc/rc.d/init.d/functions
CONQ_DIR=/usr/local/conquest
case "$1" in
start)
echo -n "Starting Conquest DICOM server: "
cd $CONQ_DIR && daemon --user mruser ./dgate -v - Starts only one process of a given name.
echo
touch /var/lock/subsys/conquest
;;
stop)
echo -n "Shutting down Conquest DICOM server: "
killproc conquest
echo
rm -f /var/lock/subsys/conquest
rm -f /var/run/conquest.pid - Only if process generates this file
;;
status)
status conquest
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reloading process-name: "
killproc conquest -HUP
echo
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
但是,cd $CONQ_DIR
由于脚本错误,因此被忽略了:
# ./conquest start
Starting Conquest DICOM server: -bash: ./dgate: No such file or directory
[FAILED]
出于某种原因,我必须将 dgate 作为 ./dgate 运行。我无法指定完整路径/usr/local/conquest/dgate
该软件带有一个用于 Debian 系统的初始化脚本,因此该脚本使用start-stop-daemon
, 并带有--chdir
dgate 所在位置的选项,但我还没有找到使用 Redhat 守护程序功能执行此操作的方法。