我的守护进程曾经在 10.04 下运行,但在 12.04 上不再自动启动。如果我手动启动它
/etc/init.d/sqlexecd 启动,它起作用了。
这是 uname -a 的输出
Linux steamboy 3.2.0-30-generic-pae
#48-Ubuntu SMP Fri Aug 24 17:14:09 UTC 2012 i686 i686 i386 GNU/Linux
以下是 chkconfig -l sqlexecd 的输出
sqlexecd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
这是守护进程。我很清楚它不会停止。
#! /bin/bash
#
# informix - Script to start/stop the Informix database servitron.
#
# Revision History:
# ewilde 2004Mar23 Initial coding.
#
# chkconfig: 2345 12 78
# description: Informix SQL database server.
# processname: sqlexecd
# config: /usr/share/informix/etc/sqlhosts
# pidfile: /var/run/informix/sqlexecd.pid
# Source function library.
#/etc/init.d/functions
# LSB compliance (kinda)
if [ -f /lib/lsb/init-functions ]; then
. /lib/lsb/init-functions;
else
log_begin_msg() { echo "$@"; };
log_success_msg() { echo "$@"; };
log_warning_msg() { echo "$@"; };
fi;
# Source networking configuration.
#. /etc/network
# Information about what and where we're running.
prog="Informix"
export INFORMIXDIR="/usr/share/informix"
lockfile="/var/lock/sqlexecd"
logfile="/var/log/sqlexecd.log"
process="sqlexecd"
service="steamboy"
owner="informix"
# Start up Informix.
start()
{
# Set up the logfile.
touch ${logfile}
chown ${owner}.${owner} ${logfile}
chmod 0664 ${logfile}
# Start the servitron.
${INFORMIXDIR}/lib/${process} ${service} -l ${logfile} >/dev/null 2>&1
# How'd that go?
ret=$?
if [ $ret -eq 0 ]; then
echo $"Starting sqlexecd: " /bin/true
else
echo $"Starting sqlexecd: " /bin/false
fi
# Locking, if necessary.
[ $ret -eq 0 ] && touch ${lockfile}
return $ret
}
# Stop Informix.
stop()
{
# If there's a lock file, try to find the PID.
if [ -f ${lockfile} ]; then
SQLPID=`ps -eo pid,args | grep ${INFORMIXDIR} | grep ${process} | sed -n 's/^ *\([0-9]*\).*/\1/p'`
if [ x"$SQLPID" != x ]; then
# Kill the PID.
kill -9 $SQLPID
ret=$?
# See how it went.
if [ $ret -eq 0 ]; then
action $"Stopping $prog: " /bin/true
else
action $"Stopping $prog: " /bin/false
fi
# Clean up the lock file.
[ $ret -eq 0 ] && rm -f ${lockfile}
return $ret
fi
fi
# Not running.
return 0
}
# Restart Informix.
restart()
{
stop
start
}
# Conditional restart of Informix.
condrestart()
{
[ -e ${lockfile} ] && restart || :
}
# See how we were called.
case "${1}" in
start)
start
;;
stop)
stop
;;
status)
ps -ef | grep sqlexecd
#status ${process}
;;
restart)
restart
;;
condrestart)
condrestart
;;
*)
echo $"Usage: $0 {start|stop|status|condrestart|restart}"
exit 1
esac
exit $?
这是日志中的错误。但是,手动启动后启动时不会发生此错误。
2012-09-08 12:28:19.475867 Starting Daemon INFORMIX-SQL Version 7.25.UC6R1
Command Line = /usr/share/informix/lib/sqlexecd steamboy -l /var/log/sqlexecd.log
INFORMIXDIR = /usr/share/informix
dbservername = steamboy
nettype = sesoctcp
hostname = steamboy
servicename = informix
options = # Well-known Informix TCP port
2012-09-08 12:28:19.478349 daemon err = -25572: Network driver cannot bind a name to the port.
System error = 99.
root@steamboy:/var/log#
我还应该配置什么才能使其自动启动?
谢谢。
编辑:
这似乎是服务运行顺序依赖性问题,此后我已将其添加到我的守护进程中,包括 #!/bin/bash 后的 -e
#!/bin/bash -e
### BEGIN INIT INFO
# Provides: sqlexecd
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start: 3 5
# Default-Stop: 1
# Short-Description: Simple script to run Informix SE daemon.
### END INIT INFO
#
这些改变都无法改变原始错误。
这是所请求的网络守护进程:
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: networking
# Required-Start:
# Required-Stop: $local_fs
# Should-Start: ifupdown
# Should-Stop: ifupdown
# Default-Start:
# Default-Stop: 0 6
# Short-Description: Raise network interfaces.
### END INIT INFO
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
[ -x /sbin/ifup ] || exit 0
. /lib/lsb/init-functions
# helper function to set the usplash timeout. https://launchpad.net/bugs/21617
usplash_timeout () {
TIMEOUT=$1
if [ -x /sbin/usplash_write ]; then
/sbin/usplash_write "TIMEOUT $TIMEOUT" || true
fi
}
process_options() {
[ -e /etc/network/options ] || return 0
log_warning_msg "/etc/network/options still exists and it will be IGNORED! Read README.Debian of netbase."
}
check_network_file_systems() {
[ -e /proc/mounts ] || return 0
if [ -e /etc/iscsi/iscsi.initramfs ]; then
log_warning_msg "not deconfiguring network interfaces: iSCSI root is mounted."
exit 0
fi
exec 9<&0 < /proc/mounts
while read DEV MTPT FSTYPE REST; do
case $DEV in
/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
log_warning_msg "not deconfiguring network interfaces: network devices still mounted."
exit 0
;;
esac
case $FSTYPE in
nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs)
log_warning_msg "not deconfiguring network interfaces: network file systems still mounted."
exit 0
;;
esac
done
exec 0<&9 9<&-
}
check_network_swap() {
[ -e /proc/swaps ] || return 0
exec 9<&0 < /proc/swaps
while read DEV MTPT FSTYPE REST; do
case $DEV in
/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
log_warning_msg "not deconfiguring network interfaces: network swap still mounted."
exit 0
;;
esac
done
exec 0<&9 9<&-
}
case "$1" in
start)
/lib/init/upstart-job networking start
;;
stop)
check_network_file_systems
check_network_swap
# Anything that manages network interfaces *MUST* wait for this event
initctl emit deconfiguring-networking
log_action_begin_msg "Deconfiguring network interfaces"
if [ "$VERBOSE" != no ]; then
if ifdown -a --exclude=lo; then
log_action_end_msg $?
else
log_action_end_msg $?
fi
else
if ifdown -a --exclude=lo >/dev/null 2>/dev/null; then
log_action_end_msg $?
else
log_action_end_msg $?
fi
fi
;;
force-reload|restart)
process_options
log_warning_msg "Running $0 $1 is deprecated because it may not enable again some interfaces"
log_action_begin_msg "Reconfiguring network interfaces"
ifdown -a --exclude=lo || true
if ifup -a --exclude=lo; then
log_action_end_msg $?
else
log_action_end_msg $?
fi
;;
*)
echo "Usage: /etc/init.d/networking {start|stop}"
exit 1
;;
esac
exit 0
答案1
Network driver cannot bind a name to the port.
我不熟悉 Informix,但我怀疑它只能在网络服务启动后启动。由于您使用的是 Red Hat 样式的 init 脚本,因此无法确保这一点。
如果你只是改变lsb 标头. 将整个sqlexecd
脚本更改为 Debian 风格并重试。