Browse Source

Implement debug mode and production mode (Copied from

snf-milter.redhat in snf-redhat distribution).

Changed version from 3.0.6  to 3.0.7.


git-svn-id: https://svn.microneil.com/svn/PKG-SNF-CS-NIX/trunk@42 233e721a-07f6-49eb-a7da-05e0e16828fc
master
adeniz 15 years ago
parent
commit
6b1611054c

+ 8
- 0
SNF_CS_Developer_Package/ChangeLog View File

@@ -1,5 +1,13 @@
2009-07-02 Alban Deniz <adeniz@skidmark.localdomain>

* Scripts/snf-server.redhat: Implement debug mode and production
mode (Copied from snf-milter.redhat in snf-redhat distribution).

2009-06-30 Alban Deniz <adeniz@skidmark.localdomain>

* Docs/DebugMode_readme.txt: Updated to be consistent with
debug/production mode capability.

* Scripts/snf-server.openbsd: Implement debug mode and production
mode (Copied from snf-milter.openbsd in snf-milter distribution).


+ 127
- 33
SNF_CS_Developer_Package/Scripts/snf-server.redhat View File

@@ -1,7 +1,6 @@
#!/bin/bash
#
# SNFServer This shell script takes care of starting and stopping
# the MicroNeil SNFServer daemon for RedHat systems.
# snf-server Starts and stops the SNFServer daemon (RedHat).
#
# Author-- Alban Deniz
#
@@ -13,13 +12,29 @@
# See www.armresearch.com for details.
# processname: SNFServer

# Directory to run in.
runDir=PREFIX/share/PACKAGE_NAME

# Define mode files.
debugModeFile=$runDir/debug_mode
productionModeFile=$runDir/production_mode

# Set debug mode flag.
if [ -f $debugModeFile ]
then
debugMode=true
fi

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Location of programs.
# Debug output file.
debugOutputFile=/var/log/PACKAGE_NAME/debug.log

# Location of installation.
installedDir="PREFIX"

# Location of programs.
@@ -29,7 +44,8 @@ dir="$installedDir/sbin"
configFile="CONFFILE"

# Name of daemon.
prog="SNFServer"
debugProg="SNFDebugServer"
productionProg="SNFServer"

# Name of client.
clientProg="SNFClient"
@@ -38,27 +54,84 @@ clientProg="SNFClient"
userName="snfilter"

# Name of lockfile.
lockFile="/var/lock/subsys/$prog"
lockFile="/var/lock/subsys/PACKAGE_NAME"

# Start command.
snfStartCmd="$dir/$prog $configFile > /dev/null 2>&1 &"
#
# Function to create the mode file.
#
createModeFile()
{
fileName=$1

# Remove any existing mode files.
rm -f $productionModeFile $debugModeFile $fileName
(
echo $"PACKAGE_NAME mode file"
echo
echo $"This file specifies whether PACKAGE_NAME is configured to run in"
echo $"production mode or debug mode. If the name of this file is"
echo $"'production_mode', then PACKAGE_NAME is configured to run in"
echo $"production mode. If the name is 'debug_mode', then PACKAGE_NAME is"
echo $"configured to run in debug mode."
echo
echo $"To run in debug mode:"
echo
echo $" 1) Run 'PACKAGE_NAME debug_mode'"
echo
echo $" 2) Run 'PACKAGE_NAME restart' (if PACKAGE_NAME is already running),"
echo $" or 'PACKAGE_NAME start' (to start PACKAGE_NAME)"
echo
echo $"To run in production mode:"
echo
echo $" 1) Run 'PACKAGE_NAME production_mode'"
echo
echo $" 2) Run 'PACKAGE_NAME restart' (if PACKAGE_NAME is already running),"
echo $" or 'PACKAGE_NAME start' (to start PACKAGE_NAME)"
echo
echo $"By default, PACKAGE_NAME is configured to run in production mode."
) > $fileName

}

start(){
SNFPID=$(pidof -s $dir/$prog)
echo -n $"Starting $prog: "
if [ -n "$SNFPID" ] ; then
echo -n $"$prog is already running"
failure
echo
return 1
echo -n $"Starting $productionProg: "
for prog in $productionProg $debugProg
do
SNFPID=$(pidof -s $dir/$prog)
if [ -n "$SNFPID" ] ; then
echo -n $"$productionProg is already running"
failure
echo
return 1
fi
done

# Start.
if [ $debugMode ]
then

# Enable core dumps and start with strace and output redirected.
(ulimit -c unlimited; \
su $userName -s /bin/sh -c \
"echo Starting $dir/$debugProg on $(date) >> $debugOutputFile"; \
cd PREFIX/share/PACKAGE_NAME; \
su $userName -c \
"strace -r -tt -v $dir/$debugProg $configFile >> $debugOutputFile 2>&1 &" \
-s /bin/sh)

else
su $userName -c "$snfStartCmd" -s /bin/sh > /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
$dir/$clientProg -status.second > /dev/null 2>&1
RETVAL=$?
fi
(cd PREFIX/share/PACKAGE_NAME; \
su $userName -c "$dir/$productionProg $configFile > /dev/null 2>&1 &" \
-s /bin/sh > /dev/null 2>&1)
fi

RETVAL=$?
if [ $RETVAL -eq 0 ]; then
$dir/$clientProg -status.second > /dev/null 2>&1
RETVAL=$?
fi

if [ $RETVAL -eq 0 ]; then
touch $lockFile
success
@@ -71,20 +144,26 @@ start(){
}

stop(){
echo -n $"Stopping $prog: "
SNFPID=$(pidof -s $dir/$prog)
if [ -n "$SNFPID" ]; then
echo -n $"Stopping $productionProg: "
DEBUG_SNFPID=$(pidof -s $dir/$debugProg)
PRODUCTION_SNFPID=$(pidof -s $dir/$productionProg)
if [ -n "$DEBUG_SNFPID" ] || [ -n "$PRODUCTION_SNFPID" ]; then
$dir/$clientProg -shutdown > /dev/null 2>&1
sleep 10
SNFPID=$(pidof -s $dir/$prog)
if [ -n "$SNFPID" ]; then
kill $SNFPID
RETVAL=$?
else
RETVAL=0
fi

# Check that the programs are no longer running.
RETVAL=0
for prog in $debugProg $productionProg
do

SNFPID=$(pidof -s $dir/$prog)
if [ -n "$SNFPID" ]; then
kill $SNFPID
RETVAL=$(($RETVAL+$?))
fi
done
else
echo -n $"$prog is not running"
echo -n $"$productionProg is not running"
RETVAL=1
failure
echo
@@ -112,13 +191,28 @@ case "$1" in
stop
;;
status)
status $prog
status $productionProg
status $debugProg
;;
restart)
restart
;;
debug_mode)
#
# Remove any mode flags, and create the debug_mode file.
#
echo $"Switching to debug mode"
createModeFile $debugModeFile
;;
production_mode)
#
# Remove any mode flags, and create the debug_mode file.
#
echo $"Switching to production mode"
createModeFile $productionModeFile
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
echo $"Usage: $0 {start|stop|status|restart|production_mode|debug_mode}"
exit 1
esac


+ 1
- 1
SNF_CS_Developer_Package/configure.ac View File

@@ -13,7 +13,7 @@ dnl
dnl
AC_PREREQ(2.52)

AC_INIT(snf-server, 3.0.6)
AC_INIT(snf-server, 3.0.7)
AC_CONFIG_SRCDIR(SNFMulti/snfCFGmgr.cpp)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)

Loading…
Cancel
Save