start.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/sh
  2. DIRNAME=$(dirname "$0")
  3. GREP="grep"
  4. DEMO_PORT=${demo.port}
  5. JAVA_OPTS="-Dserver.port=$DEMO_PORT -Dapp.server.url=http://127.0.0.1:$DEMO_PORT/"
  6. JAVA_OPTS="$JAVA_OPTS -Djava.security.egd=file:/dev/./urandom"
  7. # OS specific support (must be 'true' or 'false').
  8. cygwin=false;
  9. darwin=false;
  10. linux=false;
  11. case "`uname`" in
  12. CYGWIN*)
  13. cygwin=true
  14. ;;
  15. Darwin*)
  16. darwin=true
  17. ;;
  18. Linux)
  19. linux=true
  20. ;;
  21. esac
  22. # Setup the JVM
  23. if [ "x$JAVA" = "x" ]; then
  24. if [ "x$JAVA_HOME" != "x" ]; then
  25. JAVA="$JAVA_HOME/bin/java"
  26. else
  27. JAVA="java"
  28. fi
  29. fi
  30. if [ "$PRESERVE_JAVA_OPTS" != "true" ]; then
  31. # Check for -d32/-d64 in JAVA_OPTS
  32. JVM_D64_OPTION=`echo $JAVA_OPTS | $GREP "\-d64"`
  33. JVM_D32_OPTION=`echo $JAVA_OPTS | $GREP "\-d32"`
  34. # Check If server or client is specified
  35. SERVER_SET=`echo $JAVA_OPTS | $GREP "\-server"`
  36. CLIENT_SET=`echo $JAVA_OPTS | $GREP "\-client"`
  37. if [ "x$JVM_D32_OPTION" != "x" ]; then
  38. JVM_OPTVERSION="-d32"
  39. elif [ "x$JVM_D64_OPTION" != "x" ]; then
  40. JVM_OPTVERSION="-d64"
  41. elif $darwin && [ "x$SERVER_SET" = "x" ]; then
  42. # Use 32-bit on Mac, unless server has been specified or the user opts are incompatible
  43. "$JAVA" -d32 $JAVA_OPTS -version > /dev/null 2>&1 && PREPEND_JAVA_OPTS="-d32" && JVM_OPTVERSION="-d32"
  44. fi
  45. CLIENT_VM=false
  46. if [ "x$CLIENT_SET" != "x" ]; then
  47. CLIENT_VM=true
  48. elif [ "x$SERVER_SET" = "x" ]; then
  49. if $darwin && [ "$JVM_OPTVERSION" = "-d32" ]; then
  50. # Prefer client for Macs, since they are primarily used for development
  51. CLIENT_VM=true
  52. PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -client"
  53. else
  54. PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -server"
  55. fi
  56. fi
  57. if [ $CLIENT_VM = false ]; then
  58. NO_COMPRESSED_OOPS=`echo $JAVA_OPTS | $GREP "\-XX:\-UseCompressedOops"`
  59. if [ "x$NO_COMPRESSED_OOPS" = "x" ]; then
  60. "$JAVA" $JVM_OPTVERSION -server -XX:+UseCompressedOops -version >/dev/null 2>&1 && PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -XX:+UseCompressedOops"
  61. fi
  62. NO_TIERED_COMPILATION=`echo $JAVA_OPTS | $GREP "\-XX:\-TieredCompilation"`
  63. if [ "x$NO_TIERED_COMPILATION" = "x" ]; then
  64. "$JAVA" $JVM_OPTVERSION -server -XX:+TieredCompilation -version >/dev/null 2>&1 && PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -XX:+TieredCompilation"
  65. fi
  66. fi
  67. JAVA_OPTS="$PREPEND_JAVA_OPTS $JAVA_OPTS"
  68. fi
  69. # Find out installation type
  70. DEMO_HOME=$(cd $DIRNAME/..;pwd)
  71. DEMO_BINARY=$DEMO_HOME/lib/${project.artifactId}.jar
  72. # DEMO_CONFIG=$DEMO_HOME/config/${project.artifactId}.conf.json
  73. if [ ! -f $DEMO_BINARY ]; then
  74. DEMO_HOME=/var/lib/kurento
  75. DEMO_BINARY=$DEMO_HOME/${project.artifactId}.jar
  76. # DEMO_CONFIG="/etc/kurento/${project.artifactId}.conf.json"
  77. DEMO_OPTS="-DconfigFilePath=$DEMO_CONFIG"
  78. fi
  79. [ -f $DEMO_BINARY ] || { echo "Unable to find ${project.artifactId} binary file"; exit 1; }
  80. #[ -f $DEMO_CONFIG ] || { echo "Unable to find configuration file: $DEMO_CONFIG"; exit 1; }
  81. # Display our environment
  82. echo "========================================================================="
  83. echo ""
  84. echo " ${project.artifactId} Bootstrap Environment"
  85. echo ""
  86. echo " DEMO_BINARY: $DEMO_BINARY"
  87. echo ""
  88. echo " JAVA: $JAVA"
  89. echo ""
  90. echo " JAVA_OPTS: $JAVA_OPTS"
  91. echo ""
  92. echo "========================================================================="
  93. echo ""
  94. cd $DEMO_HOME
  95. exec $JAVA $JAVA_OPTS $DEMO_OPTS -jar $DEMO_BINARY