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 119 120 121 122 123 124 125 126 127 128 129 130 131
|
#!/bin/bash
#==========================================================================
##.TITLE ECMWF utility for ecFlow
##.NAME ecflow_stop.sh
##.SECTION ECFLOW
##.AUTHOR Avi
## Revision : $Revision: #10 $
##
## Copyright 2009- ECMWF.
## This software is licensed under the terms of the Apache Licence version 2.0
## which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
## In applying this licence, ECMWF does not waive the privileges and immunities
## granted to it by virtue of its status as an intergovernmental organisation
## nor does it submit to any jurisdiction.
##
##.FILE ecflow_stop.sh
##.INFO this file is expected to be located in /usr/local/share
## it is to be used on ecgate by member states users
## one ecf server occurrence will be generated on ecgate
#==========================================================================
#set -eux
if [[ $(hostname) = a[a-d]?-*.bullx ]]; then
echo "To use an ecFlow server on the Atos HPC at ECMWF, please read instructions: https://confluence.ecmwf.int/display/UDOC/HPC2020%3A+Using+ecFlow"
exit 0
fi
#===============================================================================
# Get the absolute path THIS script. use it to locate ecflow_client and ecflow_server
# This avoids mixing 4/5 version of ecflow.
# and need absolute since we change dir later on.
#
ECFLOW_BINDIR="$( cd "$(dirname "$0")" ; pwd -P )"
#echo "-----> ${ECFLOW_BINDIR} <-------"
PATH=$PATH:/usr/local/bin:/usr/bin
export TZ=GMT LANG=en_GB.UTG-8
host=$(hostname)
backup_server=false
# =========================================================================
# Update host, ecflow_site.sh is configured from CMAKE at install time
# =========================================================================
if [ -f ecflow_site.sh ] ; then
$(source ./ecflow_site.sh)
fi
#==========================================================================
# Syntax
# ecf_stop [-b] [-p port_number ] [-h]
# get command line options if any.
#==========================================================================
while getopts b:p: option
do
case $option in
b)
backup_server=true
;;
p)
ecf_port=$OPTARG
;;
h)
echo "Usage: $0 [-b] [-p port_number ] [-h]"
echo " -b stop ECF backup server"
echo " -p <num> specify the ECF_PORT number - default 1000+<UID> | 500+<UID> for backup server"
echo " -h print this help page"
exit 0
;;
*)
echo "Usage: $0 [-b] [-p port_number ] [-h]"
echo " -b stop ECF backup server"
echo " -p <num> specify the ECF_PORT number - default 1500+<UID> | 1000+<UID> for backup server"
echo " -h print this help page"
exit 1
;;
esac
done
#==========================================================================
# PORT NUMBER is set based on the unique users numeric uid.
username=`id -u`
if [ -z "$ecf_port" ] ; then
if [ $backup_server = "true" ]; then
base=1000
else
base=1500
fi
port_number=$((base+username))
else
port_number=$ecf_port
fi
export ECF_PORT=$port_number
#==========================================================================
# HOST
date -u
rcdir=$HOME/.ecflowrc
fname=$rcdir/$(echo $host | cut -c1-4).$USER.$ECF_PORT
# cut is useful when the server may be moved from node to node
# 4 is common string here, so that the same file is used for all nodes
if [ -f $fname ]; then host=$(cat $fname); fi
echo ""
echo "User \"$username\" attempting to stop ecf server on $host:$port_number"
echo "";
echo "Checking if the server is running on $host:$port_number"
export ECF_HOST=$host
${ECFLOW_BINDIR}/ecflow_client --ping
if [ $? -eq 1 ]; then
echo "";
echo "... The server on $host:$port_number has already been stopped"
exit 1
fi
#==========================================================================
echo "";
echo Halting, check pointing and terminating the server
${ECFLOW_BINDIR}/ecflow_client --halt=yes
${ECFLOW_BINDIR}/ecflow_client --check_pt
${ECFLOW_BINDIR}/ecflow_client --terminate=yes
exit 0
|