Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
Add proper exit codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
metmajer committed Mar 7, 2016
1 parent 70281d4 commit c59ab78
Show file tree
Hide file tree
Showing 6 changed files with 218 additions and 189 deletions.
70 changes: 37 additions & 33 deletions templates/init.d/dynaTraceAnalysis.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fi

case "$1" in
'start')
if [ -z "${PROCESSPID}" ]; then
if [ -z "${PROCESSPID}" ]; then
if [ -z "${DT_RUNASUSER}" ]; then
echo "${DT_HOME}"/${DT_BINARY} -bg ${DT_OPTARGS}
"${DT_HOME}"/${DT_BINARY} -bg ${DT_OPTARGS}
Expand All @@ -61,45 +61,49 @@ case "$1" in
su -c "${DT_HOME}/${DT_BINARY} -bg ${DT_OPTARGS}" "${DT_RUNASUSER}"
echo $! >${DT_PIDFILE}
fi
else
else
echo "Dynatrace ${DT_PRODUCT} daemon is already running!"
exit 1
fi
;;
fi
;;
'stop')
if [ -n "${PROCESSPID}" ]; then
echo "Terminating Dynatrace ${DT_PRODUCT} process ${PROCESSPID}"
kill -15 ${PROCESSPID}
COUNT=0;
while [ `ps -A -o pid | grep -c ${PROCESSPID}` -gt 0 ] && [ "${COUNT}" -lt "${DT_SHUTDOWN_WAIT}" ] # `ps --pid ${PROCESSPID} | grep -c ${PROCESSPID}` -ne 0]
do
echo "Waiting for Dynatrace ${DT_PRODUCT} (${PROCESSPID}) to finish shutdown";
sleep 1
COUNT=`expr ${COUNT} + 1`
done
if [ -n "${PROCESSPID}" ]; then
echo "Terminating Dynatrace ${DT_PRODUCT} process ${PROCESSPID}"
kill -15 ${PROCESSPID}

COUNT=0;
while [ `ps -A -o pid | grep -c ${PROCESSPID}` -gt 0 ] && [ "${COUNT}" -lt "${DT_SHUTDOWN_WAIT}" ] # `ps --pid ${PROCESSPID} | grep -c ${PROCESSPID}` -ne 0]
do
echo "Waiting for Dynatrace ${DT_PRODUCT} (${PROCESSPID}) to finish shutdown";
sleep 1
COUNT=`expr ${COUNT} + 1`
done

if [ "${COUNT}" -gt "${DT_SHUTDOWN_WAIT}" ]; then
echo "Killing Dynatrace ${DT_PRODUCT} (${PROCESSPID}) because the shutdown lasted longer than ${DT_SHUTDOWN_WAIT} seconds"
kill -9 ${PROCESSPID}
fi

if [ "${COUNT}" -gt "${DT_SHUTDOWN_WAIT}" ]; then
echo "Killing Dynatrace ${DT_PRODUCT} (${PROCESSPID}) because the shutdown lasted longer than ${DT_SHUTDOWN_WAIT} seconds"
kill -9 ${PROCESSPID}
fi
if [ -f "${DT_PIDFILE}" ]; then
rm -f ${DT_PIDFILE}
fi
fi
;;
fi
;;
'version')
"${DT_HOME}"/${DT_BINARY} -v
;;
"${DT_HOME}"/${DT_BINARY} -v
;;
'status')
if [ -n "${PROCESSPID}" ]; then
echo "Dynatrace ${DT_PRODUCT} daemon is running:"
ps -ef | grep ${DT_BINARY} | grep ${PROCESSPID}
# | grep -v org.eclipse.equinox
else
echo "Dynatrace ${DT_PRODUCT} daemon not running."
fi
;;
if [ -n "${PROCESSPID}" ]; then
echo "Dynatrace ${DT_PRODUCT} daemon is running:"
ps -ef | grep ${DT_BINARY} | grep ${PROCESSPID}
# | grep -v org.eclipse.equinox
else
echo "Dynatrace ${DT_PRODUCT} daemon not running."
exit 1
fi
;;
*)
echo "usage: $0 {start|stop|status|version}"
;;
echo "usage: $0 {start|stop|status|version}"
;;
esac

exit 0
54 changes: 29 additions & 25 deletions templates/init.d/dynaTraceBackendServer.erb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fi

case "$1" in
'start')
if [ -z "${PROCESSPID}" ]; then
if [ -z "${PROCESSPID}" ]; then
if [ -z "${DT_RUNASUSER}" ]; then
echo "${DT_HOME}"/${DT_BINARY} -bg ${DT_OPTARGS}
"${DT_HOME}"/${DT_BINARY} -bg ${DT_OPTARGS}
Expand All @@ -64,44 +64,48 @@ case "$1" in
su -c "${DT_HOME}/${DT_BINARY} -bg ${DT_OPTARGS}" "${DT_RUNASUSER}"
echo $! >${DT_PIDFILE}
fi
else
else
echo "Dynatrace ${DT_PRODUCT} daemon is already running!"
exit 1
fi
;;
fi
;;
'stop')
if [ -n "${PROCESSPID}" ]; then
if [ -n "${PROCESSPID}" ]; then
echo "Terminating Dynatrace $DT_PRODUCT process ${PROCESSPID}"
kill -15 ${PROCESSPID}

COUNT=0;
while [ `ps -A -o pid | grep -c ${PROCESSPID}` -gt 0 ] && [ "${COUNT}" -lt "${DT_SHUTDOWN_WAIT}" ] # `ps --pid ${PROCESSPID} | grep -c ${PROCESSPID}` -ne 0]
do
echo "Waiting for Dynatrace $DT_PRODUCT (${PROCESSPID}) to finish shutdown";
sleep 1
COUNT=`expr ${COUNT} + 1`
done
do
echo "Waiting for Dynatrace $DT_PRODUCT (${PROCESSPID}) to finish shutdown";
sleep 1
COUNT=`expr ${COUNT} + 1`
done

if [ "${COUNT}" -gt "${DT_SHUTDOWN_WAIT}" ]; then
echo "Killing Dynatrace $DT_PRODUCT (${PROCESSPID}) because the shutdown lasted longer than ${DT_SHUTDOWN_WAIT} seconds"
kill -9 ${PROCESSPID}
fi

if [ "${COUNT}" -gt "${DT_SHUTDOWN_WAIT}" ]; then
echo "Killing Dynatrace $DT_PRODUCT (${PROCESSPID}) because the shutdown lasted longer than ${DT_SHUTDOWN_WAIT} seconds"
kill -9 ${PROCESSPID}
fi
if [ -f "${DT_PIDFILE}" ]; then
rm -f ${DT_PIDFILE}
fi
fi
;;
fi
;;
'version')
"${DT_HOME}"/${DT_BINARY} -v
;;
"${DT_HOME}"/${DT_BINARY} -v
;;
'status')
if [ -n "${PROCESSPID}" ]; then
if [ -n "${PROCESSPID}" ]; then
echo "Dynatrace ${DT_PRODUCT} daemon is running:"
ps -ef | grep ${DT_BINARY} | grep ${PROCESSPID}
else
else
echo "Dynatrace ${DT_PRODUCT} daemon not running."
fi
;;
exit 1
fi
;;
*)
echo "usage: $0 {start|stop|status|version}"
;;
echo "usage: $0 {start|stop|status|version}"
;;
esac

exit 0
39 changes: 22 additions & 17 deletions templates/init.d/dynaTraceCollector.erb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fi

case "$1" in
'start')
if [ -z "${PROCESSPID}" ]; then
if [ -z "${PROCESSPID}" ]; then
if [ -z "${DT_INSTANCE}" ]; then
if [ -z "${DT_RUNASUSER}" ]; then
echo "${DT_HOME}"/${DT_BINARY} -bg ${DT_OPTARGS}
Expand Down Expand Up @@ -98,44 +98,49 @@ case "$1" in
echo $! >${DT_PIDFILE}
fi
fi
else
else
echo "Dynatrace ${DT_PRODUCT} daemon is already running!"
exit 1
fi
;;
fi
;;
'stop')
if [ -n "${PROCESSPID}" ]; then
if [ -n "${PROCESSPID}" ]; then
echo "Terminating Dynatrace $DT_PRODUCT process ${PROCESSPID}"
kill -15 ${PROCESSPID}

COUNT=0
while [ `ps -A -o pid | grep -c ${PROCESSPID}` -gt 0 ] && [ "${COUNT}" -lt "${DT_SHUTDOWN_WAIT}" ] # `ps --pid ${PROCESSPID} | grep -c ${PROCESSPID}` -ne 0]
do
echo "Waiting for Dynatrace ${DT_PRODUCT} (${PROCESSPID}) to finish shutdown";
sleep 1
COUNT=`expr ${COUNT} + 1`
done

if [ "${COUNT}" -gt "${DT_SHUTDOWN_WAIT}" ]; then
echo "Killing Dynatrace ${DT_PRODUCT} (${PROCESSPID}) because the shutdown lasted longer than ${DT_SHUTDOWN_WAIT} seconds"
kill -9 ${PROCESSPID}
fi

if [ -f "${DT_PIDFILE}" ]; then
rm -f ${DT_PIDFILE}
fi
fi
;;
fi
;;
'version')
"${DT_HOME}"/${DT_BINARY} -v
;;
"${DT_HOME}"/${DT_BINARY} -v
;;
'status')
if [ -n "${PROCESSPID}" ]; then
if [ -n "${PROCESSPID}" ]; then
echo "Dynatrace ${DT_PRODUCT} daemon is running:"
ps -ef | grep ${DT_BINARY} | grep ${PROCESSPID}
# | grep -v org.eclipse.equinox
else
else
echo "Dynatrace ${DT_PRODUCT} daemon not running."
fi
;;
exit 1
fi
;;
*)
echo "usage: $0 {start|stop|status|version}"
;;
esac
echo "usage: $0 {start|stop|status|version}"
;;
esac

exit 0
60 changes: 32 additions & 28 deletions templates/init.d/dynaTraceFrontendServer.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fi

case "$1" in
'start')
if [ -z "${PROCESSPID}" ]; then
if [ -z "${PROCESSPID}" ]; then
if [ -z "${DT_RUNASUSER}" ]; then
echo "${DT_HOME}"/${DT_BINARY} -bg ${DT_OPTARGS}
"${DT_HOME}"/${DT_BINARY} -bg ${DT_OPTARGS}
Expand All @@ -65,44 +65,48 @@ case "$1" in
su -c "${DT_HOME}/${DT_BINARY} -bg ${DT_OPTARGS}" "${DT_RUNASUSER}"
echo $! >${DT_PIDFILE}
fi
else
else
echo "Dynatrace ${DT_PRODUCT} daemon is already running!"
exit 1
fi
;;
fi
;;
'stop')
if [ -n "${PROCESSPID}" ]; then
echo "Terminating Dynatrace $DT_PRODUCT process ${PROCESSPID}"
kill -15 ${PROCESSPID}
if [ -n "${PROCESSPID}" ]; then
echo "Terminating Dynatrace $DT_PRODUCT process ${PROCESSPID}"
kill -15 ${PROCESSPID}

COUNT=0;
while [ `ps -A -o pid | grep -c ${PROCESSPID}` -gt 0 ] && [ "${COUNT}" -lt "${DT_SHUTDOWN_WAIT}" ] # `ps --pid ${PROCESSPID} | grep -c ${PROCESSPID}` -ne 0]
do
echo "Waiting for Dynatrace ${DT_PRODUCT} (${PROCESSPID}) to finish shutdown";
sleep 1
COUNT=`expr ${COUNT} + 1`
done
while [ `ps -A -o pid | grep -c ${PROCESSPID}` -gt 0 ] && [ "${COUNT}" -lt "${DT_SHUTDOWN_WAIT}" ] # `ps --pid ${PROCESSPID} | grep -c ${PROCESSPID}` -ne 0]
do
echo "Waiting for Dynatrace ${DT_PRODUCT} (${PROCESSPID}) to finish shutdown";
sleep 1
COUNT=`expr ${COUNT} + 1`
done

if [ "${COUNT}" -gt "${DT_SHUTDOWN_WAIT}" ]; then
echo "Killing Dynatrace ${DT_PRODUCT} (${PROCESSPID}) because the shutdown lasted longer than ${DT_SHUTDOWN_WAIT} seconds"
kill -9 ${PROCESSPID}
fi

if [ "${COUNT}" -gt "${DT_SHUTDOWN_WAIT}" ]; then
echo "Killing Dynatrace ${DT_PRODUCT} (${PROCESSPID}) because the shutdown lasted longer than ${DT_SHUTDOWN_WAIT} seconds"
kill -9 ${PROCESSPID}
fi
if [ -f "${DT_PIDFILE}" ]; then
rm -f ${DT_PIDFILE}
fi
fi
;;
fi
;;
'version')
"${DT_HOME}"/${DT_BINARY} -v
;;
"${DT_HOME}"/${DT_BINARY} -v
;;
'status')
if [ -n "${PROCESSPID}" ]; then
if [ -n "${PROCESSPID}" ]; then
echo "Dynatrace ${DT_PRODUCT} daemon is running:"
ps -ef | grep ${DT_BINARY} | grep ${PROCESSPID}
else
else
echo "Dynatrace ${DT_PRODUCT} daemon not running."
fi
;;
exit 1
fi
;;
*)
echo "usage: $0 {start|stop|status|version}"
;;
echo "usage: $0 {start|stop|status|version}"
;;
esac

exit 0
Loading

0 comments on commit c59ab78

Please sign in to comment.