Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JLigier-local.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 locally 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_US 3000
22 set_variable: DEBUG JNET_DEBUG 1
23 set_variable: WORKDIR JNET_WORKDIR ${TMPDIR:-/tmp}/
24 set_variable APPLICATION JLigier
25 
26 if do_usage $*; then
27  usage "$script [port] <option>"\
28  "\nPossible options: start, stop, continue, restart."
29 fi
30 
31 case $# in
32  2) set_variable OPTION $2
35  *) usage;;
36 esac
37 
38 if [[ $OPTION != "start" && $OPTION != "stop" && $OPTION != "continue" && $OPTION != "restart" ]]; then
39  fatal "Invalid option $OPTION."
40 fi
41 
42 #
43 # get PID
44 #
45 
46 if [[ $(uname) == "Darwin" ]]; then
47  alias get_pid="pgrep -lf '${APPLICATION} -P ${PORT}' | cut -d ' ' -f 1"
48 else
49  alias get_pid='eval ps h -o \"%p %a\" -C ${APPLICATION} | eval sed -n \"s/ \*\\\\\(\[0-9\]\*\\\\\) ${APPLICATION} \.\*-P ${PORT}\\\\\( \\\\\|\$\\\\\)\.\*/\\\1/p\"'
50 fi
51 
52 
53 if [[ $OPTION == "stop" || $OPTION == "restart" ]]; then
54 
55  PID=`get_pid`
56 
57  if [[ -n $PID ]]; then
58  notice "Stop $APPLICATION using port $PORT with PID $PID."
59  kill -9 $PID
60  fi
61 
62  OPTION=${OPTION/restart/start}
63 
64 elif [[ $OPTION == "continue" ]]; then
65 
66  PID=`get_pid`
67 
68  if [[ -n $PID ]]; then
69  notice "$APPLICATION using port $PORT is running with PID $PID."
70  else
71  OPTION=start
72  fi
73 
74 fi
75 
76 if [[ $OPTION = "start" ]]; then
77 
78  PID=`get_pid`
79 
80  if [[ -n $PID ]]; then
81  fatal "$APPLICATION using port $PORT is already running with PID $PID."
82  fi
83 
84  notice "$APPLICATION -P $PORT -T $TIMEOUT_US -d $DEBUG --! >& $WORKDIR/ligier.log"
85  nohup $APPLICATION -P $PORT -T $TIMEOUT_US -d $DEBUG --! >& $WORKDIR/ligier.log &
86 
87  for (( i = 0; $i != 20; ++i )); do
88 
89  sleep 1
90 
91  PID=`get_pid`
92 
93  if [[ -n $PID ]]; then
94  notice "$APPLICATION using port $PORT is now running with PID $PID."
95  return 0
96  fi
97  done
98 
99  error "$APPLICATION is not running on $HOST."
100 fi
101 
then usage $script< detector >< run >< outputfile > fi case set_variable OPTION
Definition: JTuna.sh:26
then usage $script[port]< option > nPossible restart fi case set_variable OPTION set_variable PORT
exit
Definition: JPizza.sh:36
then
Definition: datalogs.sh:34
const int n
Definition: JPolint.hh:786
then PID
Definition: mkqueue.sh:67
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR if do_usage *then usage $script[(input file)+] fi set_variable DEBUG set_variable WORKDIR TMPDIR
do set_variable OUTPUT_DIRECTORY $WORKDIR T
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable DEBUG set_variable WORKDIR
Definition: JLegolas.sh:20
* usage
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonStart.sh:47
then usage $script[energy[distance[z of PMT]]] fi case set_variable z
Definition: JDrawPDF.sh:45
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
then echo
Definition: JQAQC.sh:92
then elif[["$OPTION"=="count"]]
Definition: JVolume1D.sh:54
*fatal Wrong option $OPTION
then getFile sh $JPP_ARCHIVE $DETECTOR_ID $RUNS[1] $KEY $VERSION $WORKDIR
esac $JPP_BIN JLogger sh $LOGGER until pgrep JGetMessage</dev/null > dev null
then $DIR JPlotNPE PDG P
Definition: JPlotNPE-PDG.sh:62
esac done
Definition: JAddHDE.sh:21
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
do alias $i