Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JLigier.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 # \author mdejong
4 #
5 script=${0##*/}
6 
7 # ------------------------------------------------------------------------------------------
8 #
9 # Utility script to run JLigier.
10 #
11 # ------------------------------------------------------------------------------------------
12 
13 if [ -z $JPP_DIR ]; then
14  echo "Variable JPP_DIR undefined."
15  exit
16 fi
17 
18 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
19 
20 set_variable PORT 5553
21 set_variable TIMEOUT 3000
22 set_variable DEBUG ${LIGIER_DEBUG:-1}
23 set_variable HOST `get_ip_address`
24 set_variable COMMAND JLigier
26 
27 if ( do_usage $* ); then
28  print -u2 "$script [host name] <option>"
29  print -u2 "Possible options: start, stop, continue, restart."
30  exit
31 fi
32 
33 case $# in
34  2) set_variable HOST $1
35  set_variable OPTION $2;;
37  *) usage;;
38 esac
39 
40 
41 if [[ $OPTION != "start" && $OPTION != "stop" && $OPTION != "continue" && $OPTION != "restart" ]]; then
42  fatal "Invalid option $OPTION."
43 fi
44 
45 if [[ $OPTION == "stop" || $OPTION == "restart" ]]; then
46 
47  PID=`get_pid $HOST $COMMAND`
48 
49  if [[ -n $PID ]]; then
50  notice "Stop $COMMAND on $HOST with PID $PID."
51  ssh $HOST eval kill -9 $PID
52  fi
53 
54  OPTION=${OPTION/restart/start}
55 
56 elif [[ $OPTION == "continue" ]]; then
57 
58  PID=`get_pid $HOST $COMMAND`
59 
60  if [[ -n $PID ]]; then
61  notice "JLigier is running on $HOST with PID $PID."
62  else
63  OPTION=start
64  fi
65 
66 fi
67 
68 if [[ $OPTION = "start" ]]; then
69 
70  notice "Start $COMMAND on $HOST."
71  ssh $HOST "nohup $COMMAND -P $PORT -T $TIMEOUT -d $DEBUG --! >& $WORKDIR/ligier.log &"
72 
73 fi
74 
void set_variable(const std::string &name, const std::string &value)
Set environment variable.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
exit
Definition: JPizza.sh:36
then echo
*fatal Wrong option $OPTION
* usage
print
Definition: JConvertDusj.sh:44
&set_variable HOST
alias put_queue eval echo n
Definition: qlib.csh:19
then PID
then usage $script< detector >< run >< outputfile > fi case set_variable OPTION
Definition: JTuna.sh:26
then usage $script< detector file >< inputfile > fi case set_variable WORKDIR
Definition: JLegolas.sh:28
esac $JPP_BIN JLogger sh $LOGGER until pgrep JGetMessage</dev/null > dev null
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62