28f42b16177023b95676688ceb12812fac470fbe
configuration/buildAndUpdateProduct.sh
| ... | ... | @@ -277,6 +277,7 @@ if [[ "$@" == "release" ]]; then |
| 277 | 277 | cp -v $PROJECT_HOME/java/target/refreshInstance.sh $ACDIR/ |
| 278 | 278 | |
| 279 | 279 | cp -v $PROJECT_HOME/java/target/env.sh $ACDIR/ |
| 280 | + cp -v $PROJECT_HOME/java/target/env-default-rules.sh $ACDIR/ |
|
| 280 | 281 | cp -v $p2PluginRepository/configuration/config.ini configuration/ |
| 281 | 282 | |
| 282 | 283 | cp -v $PROJECT_HOME/java/target/configuration/jetty/etc/jetty.xml configuration/jetty/etc |
| ... | ... | @@ -335,7 +336,7 @@ INSTALL_FROM_RELEASE=$SIMPLE_VERSION_INFO |
| 335 | 336 | SSH_CMD="ssh $REMOTE_SERVER_LOGIN" |
| 336 | 337 | SCP_CMD="scp -r" |
| 337 | 338 | |
| 338 | - echo "Packaged release $PROJECT_HOME/dist/$SIMPLE_VERSION_INFO.tar.gz! I've put an env.sh that matches the current branch to $PROJECT_HOME/dist/$SIMPLE_VERSION_INFO/env.sh!" |
|
| 339 | + echo "Packaged release $PROJECT_HOME/dist/$SIMPLE_VERSION_INFO.tar.gz! I've put an env.sh that matches the current branch to $PROJECT_HOME/dist/$SIMPLE_VERSION_INFO/env.sh!" |
|
| 339 | 340 | |
| 340 | 341 | echo "Checking the remote connection..." |
| 341 | 342 | REMOTE_HOME=`ssh $REMOTE_SERVER_LOGIN 'echo $HOME/releases'` |
| ... | ... | @@ -816,6 +817,7 @@ if [[ "$@" == "install" ]] || [[ "$@" == "all" ]]; then |
| 816 | 817 | |
| 817 | 818 | if [ ! -f "$ACDIR/env.sh" ]; then |
| 818 | 819 | cp -v $PROJECT_HOME/java/target/env.sh $ACDIR/ |
| 820 | + cp -v $PROJECT_HOME/java/target/env-default-rules.sh $ACDIR/ |
|
| 819 | 821 | cp -v $PROJECT_HOME/java/target/configuration/monitoring.properties $ACDIR/configuration/ |
| 820 | 822 | cp -v $PROJECT_HOME/java/target/configuration/mail.properties $ACDIR/configuration/ |
| 821 | 823 | cp -v $PROJECT_HOME/java/target/configuration/logging.properties $ACDIR/configuration/ |
| ... | ... | @@ -831,6 +833,7 @@ if [[ "$@" == "install" ]] || [[ "$@" == "all" ]]; then |
| 831 | 833 | |
| 832 | 834 | # make sure to read the information from env.sh |
| 833 | 835 | . $ACDIR/env.sh |
| 836 | + . $ACDIR/env-default-rules.sh |
|
| 834 | 837 | |
| 835 | 838 | echo "$VERSION_INFO System:" > $ACDIR/configuration/jetty/version.txt |
| 836 | 839 | |
| ... | ... | @@ -901,6 +904,7 @@ if [[ "$@" == "remote-deploy" ]]; then |
| 901 | 904 | $SCP_CMD $PROJECT_HOME/java/target/configuration/mail.properties $REMOTE_SERVER_LOGIN:$REMOTE_SERVER/configuration/ |
| 902 | 905 | |
| 903 | 906 | $SCP_CMD $PROJECT_HOME/java/target/env.sh $REMOTE_SERVER_LOGIN:$REMOTE_SERVER/ |
| 907 | + $SCP_CMD $PROJECT_HOME/java/target/env-default-rules.sh $REMOTE_SERVER_LOGIN:$REMOTE_SERVER/ |
|
| 904 | 908 | $SCP_CMD $PROJECT_HOME/java/target/start $REMOTE_SERVER_LOGIN:$REMOTE_SERVER/ |
| 905 | 909 | $SCP_CMD $PROJECT_HOME/java/target/stop $REMOTE_SERVER_LOGIN:$REMOTE_SERVER/ |
| 906 | 910 | $SCP_CMD $PROJECT_HOME/java/target/status $REMOTE_SERVER_LOGIN:$REMOTE_SERVER/ |
configuration/sailing
| ... | ... | @@ -69,8 +69,8 @@ start_servers() { |
| 69 | 69 | # Example: start_server server |
| 70 | 70 | start_server() { |
| 71 | 71 | local conf="$1" |
| 72 | - echo "Starting server ${conf}" >>/var/log/sailing.err |
|
| 73 | - su - sailing -c "cd ${SERVERS_DIR}/${conf} && ./start" 2>>/var/log/sailing.err >>/var/log/sailing.err |
|
| 72 | + echo "Starting server ${conf} with SERVER_NAME=${SERVER_NAME}" >>/var/log/sailing.err |
|
| 73 | + su - sailing -c "cd ${SERVERS_DIR}/${conf} && SERVER_NAME=${SERVER_NAME} ./start" 2>>/var/log/sailing.err >>/var/log/sailing.err |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | # Call with the server directory name (not the full path, just a single element from ${JAVA_START_INSTANCE}) as parameter |
java/target/env-default-rules.sh
| ... | ... | @@ -0,0 +1,85 @@ |
| 1 | +#!/bin/bash |
|
| 2 | + |
|
| 3 | +# This file contains default rules for variable values that configure the Java server. |
|
| 4 | +# It is intended to be executed after env.sh, hence after the settings from an environment file |
|
| 5 | +# and the user data have been applied. It checks various variables for their |
|
| 6 | +# presence, and if no value is set for a variable after evaluating the base env.sh, |
|
| 7 | +# the optional environment appended from http://releases.sapsailing.com/environments, |
|
| 8 | +# and the optional user data from the EC2 environment, default values may be computed |
|
| 9 | +# which may use other variable values that *have* been set. |
|
| 10 | +if [ -z $SERVER_NAME ]; then |
|
| 11 | + SERVER_NAME=MASTER |
|
| 12 | +fi |
|
| 13 | + |
|
| 14 | +# This is a default heap size only; the boot script of an instance (see |
|
| 15 | +# configuration/sailing) will add a MEMORY assignment to this file in the |
|
| 16 | +# server's directory that has a default value computed from the total |
|
| 17 | +# memory installed in the machine and the number of server instances to |
|
| 18 | +# start on that machine. This default can be overwritten by manually appending |
|
| 19 | +# another MEMORY assignment at the end of the file or by defining an environment |
|
| 20 | +# file with a MEMORY assignment which is then used in conjunction with refreshInstance.sh |
|
| 21 | +# or by setting the MEMORY variable in the EC2 Instance Details section which will be appended |
|
| 22 | +# at the end of the file. |
|
| 23 | +if [ -z $SERVER_NAME ]; then |
|
| 24 | + MEMORY="6000m" |
|
| 25 | +fi |
|
| 26 | + |
|
| 27 | +# Message Queue hostname where to |
|
| 28 | +# send messages for replicas (this server is master) |
|
| 29 | +if [ -z $REPLICATION_HOST ]; then |
|
| 30 | + REPLICATION_HOST=rabbit.internal.sapsailing.com |
|
| 31 | +fi |
|
| 32 | +# For the port, use 0 for the RabbitMQ default or a specific port that your RabbitMQ server is listening on |
|
| 33 | +if [ -z $REPLICATION_PORT ]; then |
|
| 34 | + REPLICATION_PORT=0 |
|
| 35 | +fi |
|
| 36 | +# The name of the message queuing fan-out exchange that this server will use in its role as replication master. |
|
| 37 | +# Make sure this is unique so that no other master is writing to this exchange at any time. |
|
| 38 | +if [ -z $REPLICATION_CHANNEL ]; then |
|
| 39 | + if [ -n "$AUTO_REPLICATE" ]; then |
|
| 40 | + # This seems to be a replica; use a dedicated outbound channel for "transitive replication" |
|
| 41 | + REPLICATION_CHANNEL=${SERVER_NAME}-${INSTANCE_NAME} |
|
| 42 | + else |
|
| 43 | + # This seems to be a master (or at best a replica only regarding SecurityService / SharedSailingData). User server name |
|
| 44 | + # as the outbound replication exchange name: |
|
| 45 | + REPLICATION_CHANNEL=${SERVER_NAME} |
|
| 46 | + fi |
|
| 47 | +fi |
|
| 48 | + |
|
| 49 | +if [ -z $TELNET_PORT ]; then |
|
| 50 | + TELNET_PORT=14888 |
|
| 51 | +fi |
|
| 52 | +if [ -z $SERVER_PORT ]; then |
|
| 53 | + SERVER_PORT=8888 |
|
| 54 | +fi |
|
| 55 | +if [ -z $MONGODB_NAME ]; then |
|
| 56 | + MONGODB_NAME=${SERVER_NAME} |
|
| 57 | +fi |
|
| 58 | +if [ -z $MONGODB_PORT ]; then |
|
| 59 | + MONGODB_PORT=27017 |
|
| 60 | +fi |
|
| 61 | +if [ -z $MONGODB_HOST -a -z $MONGODB_URI ]; then |
|
| 62 | + MONGODB_URI="mongodb://mongo0.internal.sapsailing.com,mongo1.internal.sapsailing.com/${MONGODB_NAME}?replicaSet=live&retryWrites=true&readPreference=nearest" |
|
| 63 | +fi |
|
| 64 | +if [ -z $EXPEDITION_PORT ]; then |
|
| 65 | + EXPEDITION_PORT=2010 |
|
| 66 | +fi |
|
| 67 | +if [ -z $REPLICATE_MASTER_SERVLET_PORT ]; then |
|
| 68 | + REPLICATE_MASTER_SERVLET_PORT=443 |
|
| 69 | +fi |
|
| 70 | +# Host where RabbitMQ is running |
|
| 71 | +if [ -z $REPLICATE_MASTER_QUEUE_HOST ]; then |
|
| 72 | + REPLICATE_MASTER_QUEUE_HOST=rabbit.internal.sapsailing.com |
|
| 73 | +fi |
|
| 74 | +# Port that RabbitMQ is listening on (normally something like 5672); use 0 to connect to RabbitMQ's default port |
|
| 75 | +if [ -z $REPLICATE_MASTER_QUEUE_PORT ]; then |
|
| 76 | + REPLICATE_MASTER_QUEUE_PORT=0 |
|
| 77 | +fi |
|
| 78 | +# Exchange name that the master from which to auto-replicate is using as |
|
| 79 | +# its REPLICATION_CHANNEL variable, mapping to the master's replication.exchangeName |
|
| 80 | +# system property. |
|
| 81 | +# |
|
| 82 | +if [ -z $REPLICATE_MASTER_EXCHANGE_NAME ]; then |
|
| 83 | + REPLICATE_MASTER_EXCHANGE_NAME=${SERVER_NAME} |
|
| 84 | +fi |
|
| 85 | +# **** Overwritten environment variables **** |
|
| ... | ... | \ No newline at end of file |
java/target/env.sh
| ... | ... | @@ -7,55 +7,6 @@ |
| 7 | 7 | # of this file as there could be overwritten ones! |
| 8 | 8 | # ******************************************************* |
| 9 | 9 | |
| 10 | -if [ -z $SERVER_NAME ]; then |
|
| 11 | - SERVER_NAME=MASTER |
|
| 12 | -fi |
|
| 13 | - |
|
| 14 | -# This is a default heap size only; the boot script of an instance (see |
|
| 15 | -# configuration/sailing) will add a MEMORY assignment to this file in the |
|
| 16 | -# server's directory that has a default value computed from the total |
|
| 17 | -# memory installed in the machine and the number of server instances to |
|
| 18 | -# start on that machine. This default can be overwritten by manually appending |
|
| 19 | -# another MEMORY assignment at the end of the file or by defining an environment |
|
| 20 | -# file with a MEMORY assignment which is then used in conjunction with refreshInstance.sh |
|
| 21 | -# or by setting the MEMORY variable in the EC2 Instance Details section which will be appended |
|
| 22 | -# at the end of the file. |
|
| 23 | -MEMORY="6000m" |
|
| 24 | - |
|
| 25 | -# Message Queue hostname where to |
|
| 26 | -# send messages for replicas (this server is master) |
|
| 27 | -if [ -z $REPLICATION_HOST ]; then |
|
| 28 | - REPLICATION_HOST=localhost |
|
| 29 | -fi |
|
| 30 | -# For the port, use 0 for the RabbitMQ default or a specific port that your RabbitMQ server is listening on |
|
| 31 | -if [ -z $REPLICATION_PORT ]; then |
|
| 32 | - REPLICATION_PORT=0 |
|
| 33 | -fi |
|
| 34 | -# The name of the message queuing fan-out exchange that this server will use in its role as replication master. |
|
| 35 | -# Make sure this is unique so that no other master is writing to this exchange at any time. |
|
| 36 | -if [ -z $REPLICATION_CHANNEL ]; then |
|
| 37 | - REPLICATION_CHANNEL=sapsailinganalytics-master |
|
| 38 | -fi |
|
| 39 | - |
|
| 40 | -if [ -z $TELNET_PORT ]; then |
|
| 41 | - TELNET_PORT=14888 |
|
| 42 | -fi |
|
| 43 | -if [ -z $SERVER_PORT ]; then |
|
| 44 | - SERVER_PORT=8888 |
|
| 45 | -fi |
|
| 46 | -if [ -z $MONGODB_HOST ]; then |
|
| 47 | - MONGODB_HOST=10.0.75.1 |
|
| 48 | -fi |
|
| 49 | -if [ -z $MONGODB_PORT ]; then |
|
| 50 | - MONGODB_PORT=27017 |
|
| 51 | -fi |
|
| 52 | -if [ -z $MONGODB_NAME ]; then |
|
| 53 | - MONGODB_NAME=winddb |
|
| 54 | -fi |
|
| 55 | -if [ -z $EXPEDITION_PORT ]; then |
|
| 56 | - EXPEDITION_PORT=2010 |
|
| 57 | -fi |
|
| 58 | - |
|
| 59 | 10 | # To start replication upon startup provide the fully-qualified names of the Replicable service classes |
| 60 | 11 | # for which to trigger replication. If you activate this make sure to |
| 61 | 12 | # set the REPLICATE_MASTER_EXCHANGE_NAME variable to the |
| ... | ... | @@ -64,19 +15,12 @@ fi |
| 64 | 15 | if [ -n "$AUTO_REPLICATE" ]; then |
| 65 | 16 | REPLICATE_ON_START=com.sap.sailing.server.impl.RacingEventServiceImpl,com.sap.sse.security.impl.SecurityServiceImpl,com.sap.sse.filestorage.impl.FileStorageManagementServiceImpl,com.sap.sse.mail.impl.MailServiceImpl,com.sap.sailing.polars.impl.PolarDataServiceImpl,com.sap.sailing.domain.racelogtracking.impl.fixtracker.RegattaLogFixTrackerRegattaListener,com.sap.sailing.windestimation.integration.WindEstimationFactoryServiceImpl,com.sap.sailing.server.impl.com.sap.sailing.shared.server.impl.SharedSailingDataImpl |
| 66 | 17 | fi |
| 67 | -# Host where the master Java instance is running |
|
| 18 | +# Host / port where the master Java instance is running |
|
| 68 | 19 | # Make sure firewall configurations allow access |
| 69 | 20 | # |
| 70 | 21 | # REPLICATE_MASTER_SERVLET_HOST= |
| 71 | 22 | # REPLICATE_MASTER_SERVLET_PORT= |
| 72 | 23 | |
| 73 | -# Host where RabbitMQ is running |
|
| 74 | -# REPLICATE_MASTER_QUEUE_HOST= |
|
| 75 | -# Port that RabbitMQ is listening on (normally something like 5672); use 0 to connect to RabbitMQ's default port |
|
| 76 | -if [ -z $REPLICATE_MASTER_QUEUE_PORT ]; then |
|
| 77 | - REPLICATE_MASTER_QUEUE_PORT=0 |
|
| 78 | -fi |
|
| 79 | - |
|
| 80 | 24 | # Exchange name that the master from which to auto-replicate is using as |
| 81 | 25 | # its REPLICATION_CHANNEL variable, mapping to the master's replication.exchangeName |
| 82 | 26 | # system property. |
| ... | ... | @@ -166,8 +110,7 @@ fi |
| 166 | 110 | #ADDITIONAL_JAVA_ARGS="$ADDITIONAL_JAVA_ARGS -Dcom.sap.sse.debranding=true" |
| 167 | 111 | ADDITIONAL_JAVA_ARGS="$JAVA_VERSION_SPECIFIC_ARGS $ADDITIONAL_JAVA_ARGS -Dpersistentcompetitors.clear=false -Drestore.tracked.races=true -Dpolardata.source.url=https://www.sapsailing.com -Dwindestimation.source.url=https://www.sapsailing.com -XX:MaxGCPauseMillis=500" |
| 168 | 112 | |
| 169 | - |
|
| 170 | -# Custom event management URL: use -Dcom.sap.sailing.eventmanagement.url to modify hardcoded default, e.g https://dev.sapsailing.com |
|
| 113 | +# Custom event management URL: use -Dcom.sap.sailing.eventmanagement.url to modify from hardcoded default (https://my.sapsailing.com) to, e.g., https://dev.sapsailing.com |
|
| 171 | 114 | #ADDITIONAL_JAVA_ARGS="$ADDITIONAL_JAVA_ARGS -Dcom.sap.sailing.eventmanagement.url=https://dev.sapsailing.com" |
| 172 | 115 | |
| 173 | 116 | # To enable the use of the shared SecurityService and SharedSailingData from security-service.sapsailing.com, uncomment and fill in the following: |
| ... | ... | @@ -181,6 +124,4 @@ ADDITIONAL_JAVA_ARGS="$JAVA_VERSION_SPECIFIC_ARGS $ADDITIONAL_JAVA_ARGS -Dpersis |
| 181 | 124 | #REPLICATE_MASTER_BEARER_TOKEN="..." |
| 182 | 125 | |
| 183 | 126 | echo ADDITIONAL_JAVA_ARGS=${ADDITIONAL_JAVA_ARGS} |
| 184 | -ON_AMAZON=`command -v ec2-metadata` |
|
| 185 | - |
|
| 186 | -# **** Overwritten environment variables **** |
|
| 127 | +ON_AMAZON=`command -v ec2-metadata` |
|
| ... | ... | \ No newline at end of file |
java/target/refreshInstance.sh
| ... | ... | @@ -17,18 +17,15 @@ find_project_home () |
| 17 | 17 | echo "" |
| 18 | 18 | return 0 |
| 19 | 19 | fi |
| 20 | - |
|
| 21 | 20 | if [ ! -d "$1/.git" ]; then |
| 22 | 21 | PARENT_DIR=`cd $1/..;pwd` |
| 23 | 22 | OUTPUT=$(find_project_home $PARENT_DIR) |
| 24 | - |
|
| 25 | 23 | if [ "$OUTPUT" = "" ] && [ -d "$PARENT_DIR/$CODE_DIRECTORY" ] && [ -d "$PARENT_DIR/$CODE_DIRECTORY/.git" ]; then |
| 26 | 24 | OUTPUT="$PARENT_DIR/$CODE_DIRECTORY" |
| 27 | 25 | fi |
| 28 | 26 | echo $OUTPUT |
| 29 | 27 | return 0 |
| 30 | 28 | fi |
| 31 | - |
|
| 32 | 29 | echo $1 | sed -e 's/\/cygdrive\/\([a-zA-Z]\)/\1:/' |
| 33 | 30 | } |
| 34 | 31 | |
| ... | ... | @@ -95,6 +92,21 @@ activate_user_data () |
| 95 | 92 | INSTANCE_ID="$INSTANCE_NAME ($INSTANCE_IP4)" |
| 96 | 93 | } |
| 97 | 94 | |
| 95 | +append_default_envsh_rules() |
|
| 96 | +{ |
|
| 97 | + echo "# Default rules: START ($DATE_OF_EXECUTION)" >> $SERVER_HOME/env.sh |
|
| 98 | + echo "INSTANCE_NAME=`ec2-metadata -i | cut -f2 -d \" \"`" >> $SERVER_HOME/env.sh |
|
| 99 | + echo "INSTANCE_IP4=`ec2-metadata -v | cut -f2 -d \" \"`" >> $SERVER_HOME/env.sh |
|
| 100 | + echo "INSTANCE_INTERNAL_IP4=`ec2-metadata -o | cut -f2 -d \" \"`" >> $SERVER_HOME/env.sh |
|
| 101 | + echo "INSTANCE_DNS=`ec2-metadata -p | cut -f2 -d \" \"`" >> $SERVER_HOME/env.sh |
|
| 102 | + # Append EC2 user data to env.sh file: |
|
| 103 | + cat "$ec2EnvVars_tmpFile" >>$SERVER_HOME/env.sh |
|
| 104 | + |
|
| 105 | + echo "INSTANCE_ID=\"$INSTANCE_NAME ($INSTANCE_IP4)\"" >> $SERVER_HOME/env.sh |
|
| 106 | + echo "# User-Data: END" >> $SERVER_HOME/env.sh |
|
| 107 | + echo "Updated env.sh with data from user-data field!" |
|
| 108 | +} |
|
| 109 | + |
|
| 98 | 110 | append_user_data_to_envsh () |
| 99 | 111 | { |
| 100 | 112 | mkdir -p $SERVER_HOME/environment 2>/dev/null >/dev/null |
| ... | ... | @@ -126,7 +138,6 @@ install_environment () |
| 126 | 138 | echo "# Environment ($USE_ENVIRONMENT): START ($DATE_OF_EXECUTION)" >> $SERVER_HOME/env.sh |
| 127 | 139 | cat $SERVER_HOME/environment/$USE_ENVIRONMENT >> $SERVER_HOME/env.sh |
| 128 | 140 | echo "# Environment: END" >> $SERVER_HOME/env.sh |
| 129 | - |
|
| 130 | 141 | echo "Updated env.sh with data from environment file!" |
| 131 | 142 | else |
| 132 | 143 | echo "No environment file specified!" |
| ... | ... | @@ -260,8 +271,10 @@ if [[ $OPERATION == "auto-install" ]]; then |
| 260 | 271 | fi |
| 261 | 272 | # then download and install environment and append to env.sh |
| 262 | 273 | install_environment |
| 263 | - # finally, append user data to env.sh as it shall take precedence over the installed environment's defaults |
|
| 274 | + # then append user data to env.sh as it shall take precedence over the installed environment's defaults |
|
| 264 | 275 | append_user_data_to_envsh |
| 276 | + # then append the rules that compute defaults for variables not set elsewhere; this has to come last: |
|
| 277 | + append_default_envsh_rules |
|
| 265 | 278 | |
| 266 | 279 | # make sure to reload data, this time including defaults from release's env.sh, environment settings and user data |
| 267 | 280 | source `pwd`/env.sh |
java/target/start
| ... | ... | @@ -6,6 +6,9 @@ if [ "$TMP" = "" ]; then |
| 6 | 6 | fi |
| 7 | 7 | PWD=`pwd` |
| 8 | 8 | . "$PWD/env.sh" |
| 9 | +# Then set those variables not yet set explicitly, based on variables set so far |
|
| 10 | +# as well as other reasonable defaults: |
|
| 11 | +. "$PWD/env-default-rules.sh" |
|
| 9 | 12 | |
| 10 | 13 | PARAM=$@ |
| 11 | 14 |
wiki/info/landscape/amazon-ec2.md
| ... | ... | @@ -24,6 +24,8 @@ You may need to select "All generations" instead of "Current generation" to see |
| 24 | 24 | |
| 25 | 25 | Using a release, set the following in the instance's user data, replacing `myspecificevent` by a unique name of the event or series you'll be running on that instance, such as `kielerwoche2014` or similar. Note that when you select to install an environment using the `USE_ENVIRONMENT` variable, any other variable that you specify in the user data, such as the `MONGODB_URI` or `REPLICATION_CHANNEL` properties in the example above, these additional user data properties will override whatever comes from the environment specified by the `USE_ENVIRONMENT` parameter. |
| 26 | 26 | |
| 27 | +TODO describe all variable names that may be used here, as well as the defaults that apply if a variable is not specified |
|
| 28 | + |
|
| 27 | 29 | ``` |
| 28 | 30 | INSTALL_FROM_RELEASE=(name-of-release) |
| 29 | 31 | USE_ENVIRONMENT=live-master-server |