Guest User

Untitled

a guest
Nov 5th, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.78 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Licensed to the Apache Software Foundation (ASF) under one or more
  4. # contributor license agreements. See the NOTICE file distributed with
  5. # this work for additional information regarding copyright ownership.
  6. # The ASF licenses this file to You under the Apache License, Version 2.0
  7. # (the "License"); you may not use this file except in compliance with
  8. # the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17.  
  18. # OS specific support. $var _must_ be set to either true or false.
  19. cygwin=false
  20. os400=false
  21. darwin=false
  22. case "`uname`" in
  23. CYGWIN*) cygwin=true;;
  24. OS400*) os400=true;;
  25. Darwin*) darwin=true;;
  26. esac
  27.  
  28. # resolve links - $0 may be a softlink
  29. PRG="$0"
  30.  
  31. while [ -h "$PRG" ]; do
  32. ls=`ls -ld "$PRG"`
  33. link=`expr "$ls" : '.*-> \(.*\)$'`
  34. if expr "$link" : '/.*' > /dev/null; then
  35. PRG="$link"
  36. else
  37. PRG=`dirname "$PRG"`/"$link"
  38. fi
  39. done
  40.  
  41. # Get standard environment variables
  42. PRGDIR=`dirname "$PRG"`
  43.  
  44. # Only set OODT_HOME if not already set
  45. [ -z "$OODT_HOME" ] && OODT_HOME=`cd "$PRGDIR/../.." ; pwd`
  46.  
  47. # Get OODT environment set up
  48. if [ -r "$OODT_HOME"/bin/env.sh ]; then
  49. . "$OODT_HOME"/bin/env.sh
  50. fi
  51.  
  52. # Only set WORKFLOW_HOME if not already set
  53. if [ -z "$WORKFLOW_HOME" ]; then
  54. WORKFLOW_HOME="$OODT_HOME"/workflow
  55. export WORKFLOW_HOME
  56. fi
  57.  
  58. if [ -z "$WORKFLOW_PID" ]; then
  59. WORKFLOW_PID="$WORKFLOW_HOME"/run/cas.workflow.pid
  60. fi
  61.  
  62. # For Cygwin, ensure paths are in UNIX format before anything is touched
  63. if $cygwin; then
  64. [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  65. [ -n "$JRE_HOME" ] && JRE_HOME=`cygpath --unix "$JRE_HOME"`
  66. [ -n "$OODT_HOME" ] && OODT_HOME=`cygpath --unix "$OODT_HOME"`
  67. [ -n "$WORKFLOW_HOME" ] && WORKFLOW_HOME=`cygpath --unix "$WORKFLOW_HOME"`
  68. [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
  69. fi
  70.  
  71. if [ "$1" = "start" ]; then
  72. if [ ! -z "$WORKFLOW_PID" ]; then
  73. if [ -f "$WORKFLOW_PID" ]; then
  74. echo "PID file ($WORKFLOW_PID) found. Is Workflow Manager still running? Start aborted."
  75. exit 1
  76. fi
  77. fi
  78.  
  79. # In case this script was run from somewhere else cd to this directory
  80. cd "$WORKFLOW_HOME"/bin
  81.  
  82. "$_RUNJAVA" $JAVA_OPTS $OODT_OPTS \
  83. -Djava.ext.dirs="$WORKFLOW_HOME"/lib \
  84. -Djava.util.logging.config.file="$WORKFLOW_HOME"/etc/logging.properties \
  85. -Dorg.apache.oodt.cas.workflow.properties="$WORKFLOW_HOME"/etc/workflow.properties \
  86. -Djava.io.tmpdir="$OODT_TMPDIR" \
  87. -Dorg.apache.oodt.cas.pge.task.metkeys.legacyMode="true" \
  88. -Dorg.apache.oodt.cas.pge.task.status.legacyMode="true" \
  89. org.apache.oodt.cas.workflow.system.XmlRpcWorkflowManager \
  90. --portNum "$WORKFLOW_PORT" 2>&1 &
  91.  
  92. if [ ! -z "$WORKFLOW_PID" ]; then
  93. echo $! > $WORKFLOW_PID
  94. fi
  95.  
  96. if [ $have_tty -eq 1 ]; then
  97. echo "Workflow Manager started PID file ($WORKFLOW_PID)."
  98. fi
  99.  
  100. elif [ "$1" = "stop" ]; then
  101.  
  102. shift
  103.  
  104. SLEEP=5
  105. if [ ! -z "$1" ]; then
  106. echo $1 | grep "[^0-9]" > /dev/null 2>&1
  107. if [ $? -eq 1 ]; then
  108. SLEEP=$1
  109. shift
  110. fi
  111. fi
  112.  
  113. FORCE=0
  114. if [ "$1" = "-force" ]; then
  115. shift
  116. FORCE=1
  117. fi
  118.  
  119. if [ ! -z "$WORKFLOW_PID" ]; then
  120. if [ -f "$WORKFLOW_PID" ]; then
  121. kill `cat $WORKFLOW_PID` >/dev/null 2>&1
  122. if [ $? -eq 1 ]; then
  123. echo "PID file ($WORKFLOW_PID) found but no matching process was found. Stop aborted."
  124. exit 1
  125. fi
  126. else
  127. echo "\$WORKFLOW_PID was set ($WORKFLOW_PID) but the specified file does not exist. Is Workflow Manager running? Stop aborted."
  128. exit 1
  129. fi
  130. fi
  131.  
  132. if [ ! -z "$WORKFLOW_PID" ]; then
  133. if [ -f "$WORKFLOW_PID" ]; then
  134. while [ $SLEEP -ge 0 ]; do
  135. kill -0 `cat $WORKFLOW_PID` >/dev/null 2>&1
  136. if [ $? -eq 1 ]; then
  137. rm $WORKFLOW_PID
  138. break
  139. fi
  140. if [ $SLEEP -gt 0 ]; then
  141. sleep 1
  142. fi
  143. if [ $SLEEP -eq 0 ]; then
  144. if [ $FORCE -eq 0 ]; then
  145. echo "Workflow Manager did not stop in time. PID file was not removed."
  146. fi
  147. fi
  148. SLEEP=`expr $SLEEP - 1 `
  149. done
  150. fi
  151. fi
  152.  
  153. if [ $FORCE -eq 1 ]; then
  154. if [ -z "$WORKFLOW_PID" ]; then
  155. echo "Kill failed: \$WORKFLOW_PID not set"
  156. else
  157. if [ -f "$WORKFLOW_PID" ]; then
  158. echo "Killing: `cat $WORKFLOW_PID`"
  159. kill -9 `cat $WORKFLOW_PID`
  160. rm $WORKFLOW_PID
  161. fi
  162. fi
  163. fi
  164.  
  165. else
  166. echo "Usage: wmgr {start|stop}"
  167. exit 1
  168. fi
Advertisement
Add Comment
Please, Sign In to add comment