>> ras_start - мой скрипт, да думаю в этом причина. ищу пока еще
>> проблему.
> кстати покажите cat /etc/init.d/srv1cv83 если он не слишком большой. проще будет проанализировать
> зависимости запуска сервиса RAS от различных условий (ИМХО они в стандартном
> скрипте должны быть учтены).Спасибо за помощь, Ваш скрипт запуска добавил в init.d и chkconfig. Завтра потестирую, сегодня к сожалению не могу. ras по умолчанию не запускается скриптом /etc/init.d/srv1cv83 .
# chkconfig: 35 74 36
# description: Starts and stops the 1C:Enterprise daemons
#------------------------------------------------------------
# global macros. generated by install script
#------------------------------------------------------------
G_CONF_STYLE=rpm
G_VER_ARCH=i386
G_VER_MAJOR=8
G_VER_MINOR=3
G_VER_BUILD=3
G_VER_RELEASE=721
G_BINDIR="/opt/1C/v${G_VER_MAJOR}.${G_VER_MINOR}/${G_VER_ARCH}"
#------------------------------------------------------------
G_VER_SHORT=${G_VER_MAJOR}.${G_VER_MINOR}
G_TITLE="1C:Enterprise ${G_VER_SHORT} server"
#------------------------------------------------------------
# this values can be passed from outside, so perform "z-check"
#------------------------------------------------------------
[ -z "$SRV1CV8_USER" ] && SRV1CV8_USER=usr1cv8
[ -z "$SRV1CV8_BINDIR" ] && SRV1CV8_BINDIR="$G_BINDIR"
[ -z "$SRV1CV8_PIDFILE" ] && SRV1CV8_PIDFILE="/var/run/srv1cv${G_VER_MAJOR}${G_VER_MINOR}.pid"
[ -z "$SRV1CV8_KEYTAB" ] && SRV1CV8_KEYTAB="$SRV1CV8_BINDIR/$SRV1CV8_USER.keytab"
[ -z "$SRV1CV8_WAITSTART" ] && SRV1CV8_WAITSTART=5
[ -z "$SRV1CV8_WAITSTOP" ] && SRV1CV8_WAITSTOP=5
#------------------------------------------------------------
# builds ragent's command line from configuration parameters
#------------------------------------------------------------
function buildCommandLine() {
local cmdline="$SRV1CV8_BINDIR/ragent -daemon"
[ ! -z "$SRV1CV8_PORT" ] && cmdline="$cmdline -port $SRV1CV8_PORT"
[ ! -z "$SRV1CV8_REGPORT" ] && cmdline="$cmdline -regport $SRV1CV8_REGPORT"
[ ! -z "$SRV1CV8_DATA" ] && cmdline="$cmdline -d \"$SRV1CV8_DATA\""
[ ! -z "$SRV1CV8_RANGE" ] && cmdline="$cmdline -range $SRV1CV8_RANGE"
[ ! -z "$SRV1CV8_SECLEV" ] && cmdline="$cmdline -seclev $SRV1CV8_SECLEV"
[ "x$SRV1CV8_DEBUG" == "x1" ] && cmdline="$cmdline -debug"
echo $cmdline
}
#------------------------------------------------------------
# checks if process with passed pid exists
function checkpid() {
ps -p $* > /dev/null
}
#------------------------------------------------------------
# waits SRV1CV8_WAITSTOP seconds for process termination,
# then kills it
#------------------------------------------------------------
function delayedkill() {
local mypid=$1
local delay=$2
kill $mypid 2>/dev/null
checkpid $mypid && sleep $delay || return 0
if checkpid $mypid; then
kill -9 $mypid
logWarning "Process refused to die... So it was killed. May be you should increase SRV1CV8_WAITSTOP variable?";
fi
return 0
}
#------------------------------------------------------------
# extracts specified param from value from given command-line
#------------------------------------------------------------
function extractParam() {
local param=$1
shift
local tmp=$*
if [ ! -z "$*" ]; then
if [ ${tmp:0:1} == "-" ]; then
tmp=${tmp:1}
local val=${tmp#*$param }
# if old and new strings are equal
# we don't have needed param in cmdline
# so return
[ "$val" == "$tmp" ] && return;
val=${val%% -*}
echo "$val"
fi
fi
}
#------------------------------------------------------------
# call it when something fails
#------------------------------------------------------------
function failure() {
[ "$BOOTUP" != "verbose" -a -z "$LSB" ] && echo FAILED
return 0
}
#------------------------------------------------------------
# extracts data dir from ragent's command line or (if it's
# empty), builds it from users's home dir
#------------------------------------------------------------
function getDataDir() {
local cmdline=`getRagentRealCmdLine`
local datadir="$SRV1CV8_DATA"
[ ! -z "$cmdline" ] && datadir=`extractParam d $cmdline`
if [ -z "$datadir" ]; then
local line=`grep ^$SRV1CV8_USER: /etc/passwd`
local homedir=${line#*:*:*:*:*:}
homedir=${homedir%:*}
datadir="$homedir/.1cv${G_VER_MAJOR}${G_VER_MINOR}/1C/1Cv${G_VER_MAJOR}${G_VER_MINOR}"
fi
echo $datadir
}
#------------------------------------------------------------
# returns ragent configuration debug flag
#------------------------------------------------------------
function getDebugStatus() {
local cmdline=`getRagentRealCmdLine`
local debugFlag="$SRV1CV8_DEBUG"
echo "$cmdline" | grep "\-debug" >/dev/null && debugFlag="1"
[ ! -z "$debugFlag" ] && echo $debugFlag || echo "0"
}
#------------------------------------------------------------
# returns ragent port range
#------------------------------------------------------------
function getPortRange() {
local cmdline=`getRagentRealCmdLine`
local range="$SRV1CV8_RANGE"
[ ! -z "$cmdline" ] && range=`extractParam range $cmdline`
[ ! -z "$range" ] && echo $range || echo 1560:1591
}
#------------------------------------------------------------
# returns ragent main port
#------------------------------------------------------------
function getRagentPort() {
local cmdline=`getRagentRealCmdLine`
local port="$SRV1CV8_PORT"
[ ! -z "$cmdline" ] && port=`extractParam port $cmdline`
[ ! -z "$port" ] && echo $port || echo 1540
}
#------------------------------------------------------------
# get's running ragent command-line
#------------------------------------------------------------
function getRagentRealCmdLine() {
local cmdline=`buildCommandLine`
local mypid=`getRagentPid "$SRV1CV8_USER" "$cmdline"`
local result=""
[ ! -z "$mypid" ] && result=`ps --pid $mypid -o cmd= | sed -e "s/.*-daemon//"`
echo "$result"
}
#------------------------------------------------------------
# tries to get pid of ragent process, started by this script
#------------------------------------------------------------
function getRagentPid() {
local user=$1
shift
# remove quotes in passed CMDLINE because
# command line of process doesn't contains'em
# even if they were passed.
local cmdline=`echo $* | sed -e "s/\"//g"`
ps -C ragent -opid=,user=,cmd= | while read curline; do
local curPID=`echo $curline | sed -e "s/ .*//"`
local curline=`echo $curline | sed -e "s/$curPID //"`
local curUSR=`echo $curline | sed -e "s/ .*//"`
local curCMD=`echo $curline | sed -e "s/$curUSR //"`
if [ "$curCMD" == "$cmdline" ] && [ "$curUSR" == "$user" ]; then
echo $curPID
fi
done
}
#------------------------------------------------------------
# returns ragent reg port
#------------------------------------------------------------
function getRegPort() {
local cmdline=`getRagentRealCmdLine`
local regport="$SRV1CV8_REGPORT"
[ ! -z "$cmdline" ] && regport=`extractParam regport $cmdline`
[ ! -z "$regport" ] && echo $regport || echo 1541
}
#------------------------------------------------------------
# returns name of script
#------------------------------------------------------------
function getScriptName() {
local myname=`basename $0`
[ ${myname:0:1} = "S" -o ${myname:0:1} = "K" ] && myname=${myname:3}
echo $myname
}
#------------------------------------------------------------
# returns ragent security level
#------------------------------------------------------------
function getSecLevel() {
local cmdline=`getRagentRealCmdLine`
local seclev="$SRV1CV8_SECLEV"
[ ! -z "$cmdline" ] && seclev=`extractParam seclev $cmdline`
[ ! -z "$seclev" ] && echo $seclev || echo 0
}
#------------------------------------------------------------
# displays useful information about ragent
#------------------------------------------------------------
function info() {
echo "$G_TITLE info:"
echo -n " Data dir: " && getDataDir
echo -n " Main port: " && getRagentPort
echo -n " RegPort: " && getRegPort
echo -n "Port range: " && getPortRange
echo -n "Debug mode: " && getDebugStatus
echo -n "Sec. level: " && getSecLevel
return 0
}
#------------------------------------------------------------
# check if our ragent running
[ ! -d "$SRV1CV8_DATA" ] && { logError "SRV1CV8_DATA \"$SRV1CV8_DATA\" is a file, not a directory!"; return 0; }
fi
fi
[ ! -f "$SRV1CV8_BINDIR/ragent" ] && { logError "ragent file does not exists!" ; return 0; }
[ ! -x "$SRV1CV8_BINDIR/ragent" ] && { logError "ragent file is not executable!"; return 0; }
local cmd2run=`buildCommandLine`
if isRagentRunning "$SRV1CV8_USER" "$cmd2run"; then
logWarning "already started!";
else
# run our process
if [ -z "$SRV1CV8_USER" ]; then
export KRB5_KTNAME="$SRV1CV8_KEYTAB"
$cmd2run
else
su -s /bin/bash - "$SRV1CV8_USER" -c "KRB5_KTNAME=\"$SRV1CV8_KEYTAB\" $cmd2run"
fi
sleep $SRV1CV8_WAITSTART # wait a bit before check
! isRagentRunning "$SRV1CV8_USER" "$cmd2run" && { logError "service failed to start!"; return 0; }
# check if pidfile exists and remove it if neccessary
[ -f "$SRV1CV8_PIDFILE" ] && logWarning "pid file existed on server start. it can mean that last run failed..."
fi
local mypid=`getRagentPid $SRV1CV8_USER $cmd2run`
echo ${mypid} > "$SRV1CV8_PIDFILE"
success
return 0
}
#------------------------------------------------------------
# displays ragent status
#------------------------------------------------------------
function status() {
echo "$G_TITLE status:"
echo -n "Init script: "
if [ -f "$SRV1CV8_PIDFILE" ]; then
echo STARTED.
local cmd2run=`buildCommandLine`
echo -n " Ragent: "
! isRagentRunning "$SRV1CV8_USER" "$cmd2run" && echo -n "NOT "
echo "RUNNING."
else
echo NOT STARTED.
fi
return 0
}
#------------------------------------------------------------
# stops ragent
#------------------------------------------------------------
function stop() {
echo -n "Stopping $G_TITLE: "
[ -f "$SRV1CV8_PIDFILE" ] && rm "$SRV1CV8_PIDFILE"
local cmd2run=`buildCommandLine`
if isRagentRunning "$SRV1CV8_USER" "$cmd2run"; then
mypid=`getRagentPid $SRV1CV8_USER $cmd2run`
if [ ! -z "$mypid" ]; then
local childpids=`ps --ppid ${mypid} -o pid=`
delayedkill $mypid $SRV1CV8_WAITSTOP
for childpid in $childpids; do
delayedkill $childpid $SRV1CV8_WAITSTOP
done
fi
else
logWarning "server not running!"
fi
success
return
}
#------------------------------------------------------------
# functions says something succeded
#------------------------------------------------------------
function success() {
[ "$BOOTUP" != "verbose" -a -z "$LSB" ] && echo OK
return 0
}
#------------------------------------------------------------
# script's main function
function main() {
local myname=`getScriptName`
local dirname=`dirname $0`
local realdir=$(cd "$dirname"; pwd)
# check if someone passed different config throug command-line option
local configFile=
[ "$1" == "-c" ] && { configFile="$2"; shift 2; }
local action=
case $1 in
'')
showUsage $myname
return 1
;;
--help)
showUsage $myname
return 0
;;
info)
action=info
;;
restart)
action=restart
;;
start)
action=start
;;
status)
action=status
;;
stop)
action=stop
;;
*)
showUsage $myname
return 1;
;;
esac
# check for config file existence
if [ -z "$configFile" ]; then
configFile="/etc/sysconfig/$myname"
if [ -z "$configFile" ]; then
configFile="/etc/sysconfig/$myname"
[ -e "$configFile" ] && source "$configFile"
else
[ -f "$configFile" ] && source "$configFile"
fi
$action
}
#invoke function main
main $*
Огромный....