File: gtcm_run.gtc

package info (click to toggle)
fis-gtm 6.3-007-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 36,284 kB
  • sloc: ansic: 328,861; asm: 5,182; csh: 5,102; sh: 1,918; awk: 291; makefile: 69; sed: 13
file content (118 lines) | stat: -rwxr-xr-x 3,687 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/sh
#################################################################
#								#
#	Copyright 2001, 2012 Fidelity Information Services, Inc #
#								#
#	This source code contains the intellectual property	#
#	of its copyright holder(s), and is made available	#
#	under a license.  If you do not know the terms of	#
#	the license, please stop and do not read further.	#
#								#
#################################################################
# gtcm_run - This script is used to start an invidiaul GTCM server
# Usually this is called from gtmstart script
#
# If the GTCM_RESTART environment variable is set to 1, this script will
# restart the server if some event causes it to stop running.
#

# set maximum number of failures per period in minutes
arch=ARCH
maxfails=5
period=10
server=${GTCM_SERVER-GTMDIST/gtcm_server}
logdir=$gtm_dist/log
cwd=`pwd`
restart=${GTCM_RESTART-0}
echo=ECHO
options=
service=omi

fails=0

if [ $# -lt 1 ]
then
        $echo "$0:  You must specify command-line options to $server."
        exit 1
fi

while [ $# -ne 0 ]
do
        case $1 in
                -service)
			shift
			service=$1
			logdir=${logdir}/${service}
			;;
                *)
			options="$options $1" ;;
        esac
        shift
done
# In case, instead of running gtmstart, this script is run directly to start gtcm server,
# $logdir may not be present, so create it
if [ ! -d $logdir ]
then
	$echo "GT.M/GT.CM logging directory ($logdir) does not exist, creating it..."
	mkdir -p $logdir
fi
oldservcnt=`ps -ea|grep gtcm_server |wc -l`

$echo
t0=`date '+%j %H %M' | awk '{ print $1 * 60 * 24 + $2 * 60 + $3 }'`
while [ $fails -le $maxfails ]
do
        $echo "Starting server:  \"$server $*\" on `date`."
	startstatus=1
        $server -service $service $options >> $logdir/gtcm_server.log$fails 2>&1
	sleep 1
	newservcnt=`ps -ea|grep gtcm_server | wc -l `
	if [ $newservcnt -gt $oldservcnt ]
	then
		startstatus=0
	fi

        if [ -r $cwd/core ]
        then
		if `strings $cwd/core | egrep 'image_id=gtcm_server.*-service '$service >/dev/null 2>&1`
		then
			corename=`date "+core_${service}%m%d%H%M%S"`
			$echo "core file in $cwd has been generated by GT.CM"
        	        $echo "core file moved to $logdir/$corename"
	                mv $cwd/core $logdir/$corename
		fi
        fi

        # abort if we gave no restart option or current try of starting gtcm server is successful
	if [ $startstatus -eq 0 ]
        then
		$echo
		$echo "**********************************************************************"
		$echo "$0, service $service started on `date`"
		$echo "**********************************************************************"
		$echo
                exit 1
        else
                if [ $restart -eq 0 ]
                then
                        $echo "**********************************************************************"
                        $echo " service: $service failed to start"
                        $echo "**********************************************************************"
			$echo "Please look into $gtm_dist/log/gtcm_server.erlg file and  syslog messages."
                        exit 1
                fi
        fi
        echo "(restart is enabled) Retry to start service: $service"

        t1=`date '+%j %H %M' | awk '{ print $1 * 60 * 24 + $2 * 60 + $3 }'`
        delta=`expr $t1 - $t0`
        fails=`expr $fails + 1`
        if [ $delta -gt $period  -o $delta -lt 0 ]
        then
                fails=1
                t0=$t1
        fi
        sleep 10
done
$echo "ABORT:  more than $maxfails failures in $period minutes."
$echo "Please look into $gtm_dist/log/gtcm_server.erlg file and  syslog messages."