Skip to content

Commit e4e351f

Browse files
committed
informatica init.d script now working
1 parent d69feee commit e4e351f

File tree

1 file changed

+174
-25
lines changed

1 file changed

+174
-25
lines changed

Oracle Scripts/Informatica/init.d/informatica

100644100755
Lines changed: 174 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ INFOSERVICE=/APPS/Informatica/9.0.1/server/tomcat/bin
2727
# log file path, change if you don't want logs to go to /var/log
2828
LOG_PATH=/var/log
2929

30-
3130
# the following variables should not need modification
3231
SUBSYS=$(basename $0)
33-
INFO_FINGERPRINT='pmrepagent'
34-
INFO_START_TIMEOUT=300
35-
INFO_STOP_TIMEOUT=300
36-
LOCK_FILE='var/lock/subsys/'$SUBSYS
32+
INFO_FINGERPRINT='Djava.awt.headless=true'
33+
START_TIMEOUT=300
34+
STOP_TIMEOUT=300
35+
LOCK_FILE='/var/lock/subsys/'$SUBSYS
3736
START_LOG=$LOG_PATH/$SUBSYS-start.log
3837
STOP_LOG=$LOG_PATH/$SUBSYS-stop.log
3938
LSOF_PATH=/usr/sbin/lsof
39+
ORACLE_OWNR=oracle
4040
# source the functions library
4141
#-----------------------
4242
if [ -f /etc/rc.d/init.d/functions ]; then
@@ -47,7 +47,7 @@ fi
4747
# check paths and permissions
4848
if [ ! -f $INFOSERVICE/infaservice.sh ] ; then
4949
echo ''
50-
echo -n "**infaservice.sh file not found at $INFOSERVICE/infraservice.sh"
50+
echo -n "**infaservice.sh file not found at $INFOSERVICE/infaservice.sh"
5151
echo_failure
5252
echo ''
5353
fi
@@ -126,24 +126,24 @@ check_permissions() {
126126
#
127127

128128
check_process_ports () {
129-
# Pass the 'fingerprint' of the process to check, which should be a regex to uniquely
130-
# identify the process in a pgrep -f call
131-
#
132-
# Returns:
133-
# 0 - Process not running
134-
# 1 - Process running but not listening on any port
135-
# <ports> - the port(s) on which the process is listening
136-
PID=$(pgrep -f $1)
137-
if [ $? -eq 0 ] ; then
138-
PORT=$(pgrep -f $1|xargs -I'{}' $LSOF_PATH -nPp {}|grep LISTEN|awk -F ":" '{print $2}'|cut -d " " -f 1|sort -u|paste -s)
139-
if [ -n "$PORT" ] ; then
140-
echo $PORT
141-
else
142-
echo 1
143-
fi
144-
else
145-
echo 0
146-
fi
129+
# Pass the 'fingerprint' of the process to check, which should be a regex to uniquely
130+
# identify the process in a pgrep -f call
131+
#
132+
# Returns:
133+
# 0 - Process not running
134+
# 1 - Process running but not listening on any port
135+
# <ports> - the port(s) on which the process is listening
136+
PID=$(pgrep -f $1)
137+
if [ $? -eq 0 ] ; then
138+
PORT=$(pgrep -f $1|xargs -I'{}' $LSOF_PATH -nPp {}|grep LISTEN|awk -F ":" '{print $2}'|cut -d " " -f 1|sort -u|paste -s)
139+
if [ -n "$PORT" ] ; then
140+
echo $PORT
141+
else
142+
echo 1
143+
fi
144+
else
145+
echo 0
146+
fi
147147
}
148148

149149

@@ -163,6 +163,136 @@ echo_process_status () {
163163
echo ' '
164164
}
165165

166+
wait_to_die() {
167+
# check_process_ports will return 0 (not running), 1 (starting up) or other (port value)
168+
# This function will poll the process and based on the value returned (in rc) keep polling,
169+
# or after the predefined timeout period, kill the process by force.
170+
rc=999
171+
timeout=$2
172+
if [ -z $timeout ] ; then
173+
timeout=600
174+
fi
175+
# 30 is enough space on the line for the . to appear without overlapping the status message
176+
sleep_period=$(($timeout/30))
177+
[[ $sleep_period -eq 0 ]] && sleep_period=1
178+
fingerprint=$1
179+
starttime=$(date +%s)
180+
while [ "$rc" != "0" ]
181+
do
182+
rc=$(check_process_ports $fingerprint)
183+
nowtime=$(date +%s)
184+
timediff=$(( $nowtime - $starttime ))
185+
if [ $timediff -gt $timeout ] ; then
186+
echo_warning
187+
echo ''
188+
echo -e '\tTimed out after '$timeout' seconds'
189+
echo -en '\tSending SIGKILL. '
190+
pkill -SIGKILL -f $fingerprint
191+
sleep 5
192+
rc=$(check_process_ports $1)
193+
case "$rc" in
194+
0)
195+
echo -n 'Process killed'
196+
echo_success
197+
;;
198+
*)
199+
echo -n "Process still running"
200+
echo_failure
201+
esac
202+
echo ''
203+
return 1
204+
fi
205+
echo -n '.'
206+
if [ "$rc" != "0" ] ; then
207+
sleep $sleep_period
208+
fi
209+
done
210+
echo_success
211+
echo ''
212+
return 0
213+
}
214+
215+
wait_to_start() {
216+
# check_process_ports will return 0 (not running), 1 (starting up) or other (port value)
217+
# This function will poll the process and based on the value returned (in rc) keep polling,
218+
# or after the predefined timeout period, give up.
219+
rc=1
220+
timeout=$2
221+
if [ -z $timeout ] ; then
222+
timeout=600
223+
fi
224+
# 30 is enough space on the line for the . to appear without overlapping the status message
225+
sleep_period=$(($timeout/30))
226+
[[ $sleep_period -eq 0 ]] && sleep_period=1
227+
fingerprint=$1
228+
#echo 'Timeout: '$timeout ', Sleep period: '$sleep_period', Fingerprint: '$fingerprint
229+
starttime=$(date +%s)
230+
while [ "$rc" == "1" ]
231+
do
232+
sleep $sleep_period
233+
rc=$(check_process_ports $fingerprint)
234+
nowtime=$(date +%s)
235+
timediff=$(( $nowtime - $starttime ))
236+
if [ $timediff -gt $timeout ] ; then
237+
echo -n ' '
238+
echo -n ' (Timed out after '$timeout' seconds ) '
239+
break
240+
fi
241+
echo -n '.'
242+
done
243+
case "$rc" in
244+
0|1)
245+
echo_failure
246+
rc=255
247+
;;
248+
*)
249+
echo_success
250+
rc=0
251+
;;
252+
esac
253+
echo ''
254+
#echo '--'
255+
#echo $rc
256+
#echo '--'
257+
return $rc
258+
}
259+
260+
echo_not_running() {
261+
[ "$BOOTUP" = "color" ] && $MOVE_TO_COL
262+
echo -n "["
263+
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
264+
echo -n $"NOT RUNNING"
265+
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
266+
echo -n "]"
267+
echo -ne "\r"
268+
return 1
269+
}
270+
271+
echo_in_progress() {
272+
[ "$BOOTUP" = "color" ] && $MOVE_TO_COL
273+
echo -n "["
274+
[ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
275+
echo -n $"IN PROGRESS"
276+
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
277+
echo -n "]"
278+
echo -ne "\r"
279+
return 1
280+
}
281+
282+
start() {
283+
echo -en "\nStarting Informatica Server"
284+
su - $ORACLE_OWNR -c "$INFOSERVICE/infaservice.sh startup &" > $START_LOG 2>&1 &
285+
wait_to_start $INFO_FINGERPRINT $START_TIMEOUT
286+
}
287+
288+
stop () {
289+
echo -en "\nStopping Informatica Server"
290+
su $ORACLE_OWNR -c "$INFOSERVICE/infaservice.sh shutdown" > $STOP_LOG 2>&1 &
291+
wait_to_die $INFO_FINGERPRINT $STOP_TIMEOUT
292+
}
293+
294+
295+
166296
status () {
167297
echo ''
168298
echo -n ' Checking Informatica Server: '
@@ -173,7 +303,26 @@ status () {
173303
case $1 in
174304
status)
175305
status
176-
;;
306+
;;
307+
start)
308+
check_permissions
309+
start
310+
echo ''
311+
touch $LOCK_FILE
312+
;;
313+
stop)
314+
check_permissions
315+
stop
316+
rm -f $LOCK_fILE
317+
;;
318+
restart)
319+
check_permissions
320+
stop
321+
start
322+
;;
323+
*)
324+
echo "Usage: $(basename $0) start|stop|restart|status"
325+
;;
177326
esac
178327

179328

0 commit comments

Comments
 (0)