bug4811: fixed "sailing" init.d script

This commit is contained in:
EC2 Server committed 2020-11-19 14:37:32 +00:00
1 parent dbf8ce0ef2
commit 2bde16be68
1 file changed
+17 -16
+17 -16
View File
@@ -22,15 +22,16 @@
RETVAL=0
JAVA_START_INSTANCES="$(find \"${SERVERS_DIR}/*\" -type d -prune)"
SERVERS_DIR=/home/sailing/servers
cd "${SERVERS_DIR}"
JAVA_START_INSTANCES="$(find * -type d -prune)"
GIT_REPOSITORY=/home/sailing/code
APACHE_CONFIG_DIR=/etc/httpd/conf.d
APACHE_INTERNALS_CONFIG_FILE="$APACHE_CONFIG_DIR/001-internals.conf"
EC2_METADATA_CMD=/opt/aws/bin/ec2-metadata
REBOOT_INDICATOR=/var/run/is-rebooted
echo "Executing with $1" >>/var/log/sailing.out
echo "Executing with $1 at `date`" >>/var/log/sailing.err
start_tmux() {
su - sailing -c "/home/sailing/bin/tmuxConsole.sh unattended"
@@ -56,8 +57,8 @@ start_servers() {
if [ ${NUMBER_OF_INSTANCES} -gt 1 ]; then
echo "More than one server cannot be configured from user data; only configuring ${FIRST_SERVER}" >>/var/log/sailing.err
fi
create_basic_httpd_config
configure_and_start_server "${FIRST_SERVER}"
create_basic_httpd_config
reload_httpd
echo 1 >"${REBOOT_INDICATOR}"
fi
@@ -69,7 +70,7 @@ start_servers() {
start_server() {
local conf="$1"
echo "Starting server ${conf}" >>/var/log/sailing.err
su - sailing -c "cd ${SERVERS_DIR}/${conf} && ./start" 2>>/var/log/sailing.err >>/var/log/sailing.out
su - sailing -c "cd ${SERVERS_DIR}/${conf} && ./start" 2>>/var/log/sailing.err >>/var/log/sailing.err
}
# Call with the server directory name (not the full path, just a single element from ${JAVA_START_INSTANCE}) as parameter
@@ -86,7 +87,7 @@ configure_and_start_server() {
MEMORY_PER_INSTANCE_IN_MB=$(( $MEMORY_COMPUTED < $MINIMUM_MEMORY_IN_MB ? $MINIMUM_MEMORY_IN_MB : $MEMORY_COMPUTED ))
echo "Using ${MEMORY_PER_INSTANCE_IN_MB}MB as default heap size per instance." >>/var/log/sailing.err
echo "MEMORY=\"${MEMORY_PER_INSTANCE_IN_MB}m\"" >>$SERVERS_DIR/$conf/env.sh
su - sailing -c "cd ${SERVERS_DIR}/${conf} && ${GIT_REPOSITORY}/java/target/refreshInstance.sh auto-install" 2>>/var/log/sailing.err >>/var/log/sailing.out
su - sailing -c "cd ${SERVERS_DIR}/${conf} && ${GIT_REPOSITORY}/java/target/refreshInstance.sh auto-install" 2>>/var/log/sailing.err >>/var/log/sailing.err
(
# execute env.sh in a subshell which now has the same set of variables that the server will see
source $SERVERS_DIR/$conf/env.sh
@@ -108,16 +109,16 @@ configure_and_start_server() {
else
# Now loop over all EVENT_ID specification keys and produce an "Event-SSL" macro invocation for each:
for i in ${!EVENT_ID[*]}; do
echo "Appending macro invocation to ${reverse_proxy_config_file} to map ${EVENT_HOSTNAME[$i]} to event with ID ${EVENT_ID[$i]} with server running on local port $SERVER_PORT..." >>/var/log/sailing.out
echo "Appending macro invocation to ${reverse_proxy_config_file} to map ${EVENT_HOSTNAME[$i]} to event with ID ${EVENT_ID[$i]} with server running on local port $SERVER_PORT..." >>/var/log/sailing.err
echo "## EVENT ${EVENT_HOSTNAME[$i]}" >>"${reverse_proxy_config_file}"
echo "Use Event-SSL ${EVENT_HOSTNAME[$i]} \"${EVENT_ID[$i]}\" 127.0.0.1 $SERVER_PORT" >>"${reverse_proxy_config_file}"
fi
done
# Now loop over all SERIES_ID specification keys and produce an "Series-SSL" macro invocation for each:
for i in ${!SERIES_ID[*]}; do
echo "Appending macro invocation to ${reverse_proxy_config_file} to map ${SERIES_HOSTNAME[$i]} to event with ID ${SERIES_ID[$i]} with server running on local port $SERVER_PORT..." >>/var/log/sailing.out
echo "Appending macro invocation to ${reverse_proxy_config_file} to map ${SERIES_HOSTNAME[$i]} to event with ID ${SERIES_ID[$i]} with server running on local port $SERVER_PORT..." >>/var/log/sailing.err
echo "## SERIES ${SERIES_HOSTNAME[$i]}" >>"${reverse_proxy_config_file}"
echo "Use Event-SSL ${SERIES_HOSTNAME[$i]} \"${SERIES_ID[$i]}\" 127.0.0.1 $SERVER_PORT" >>"${reverse_proxy_config_file}"
fi
done
fi
# terminating the subshell will forget all the variable assignments brought in by env.sh, clearing for the next server instance
)
@@ -127,7 +128,7 @@ configure_and_start_server() {
stop_servers() {
for conf in $JAVA_START_INSTANCES; do
echo "Stopping Java server $conf" >> /var/log/sailing.out
echo "Stopping Java server $conf" >> /var/log/sailing.err
su - sailing -c "cd $SERVERS_DIR/$conf && ./stop"
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
@@ -137,15 +138,15 @@ stop_servers() {
}
sync_logs() {
echo "Executing logrotate followed by a sync to ensure that logs are synchronized" >> /var/log/sailing.out
echo "Executing logrotate followed by a sync to ensure that logs are synchronized" >> /var/log/sailing.err
logrotate -f /etc/logrotate.conf
sync
}
reload_httpd() {
echo "Will try to launch httpd so this replica can work with an ELB easily." >>/var/log/sailing.out
echo "Will try to launch httpd so this replica can work with an ELB easily." >>/var/log/sailing.err
if [ -x /etc/init.d/httpd ]; then
echo "Reloading httpd configuration..." >>/var/log/sailing.out
echo "Reloading httpd configuration..." >>/var/log/sailing.err
service httpd reload
else
echo "Can't launch httpd; start script doesn't seem to be installed at /etc/init.d/httpd"
@@ -156,10 +157,10 @@ reload_httpd() {
create_basic_httpd_config() {
FIRST_SERVER=`echo $JAVA_START_INSTANCES | awk '{print $1;}'`
source $SERVERS_DIR/$FIRST_SERVER/env.sh
echo "Appending macro invocation to ${APACHE_INTERNALS_CONFIG_FILE} to map internal IP $INSTANCE_INTERNAL_IP4 to plain server running $SERVER_PORT..." >>/var/log/sailing.out
echo "Appending macro invocation to ${APACHE_INTERNALS_CONFIG_FILE} to map internal IP $INSTANCE_INTERNAL_IP4 to plain server running $SERVER_PORT..." >>/var/log/sailing.err
echo "Use Plain-SSL ${INSTANCE_INTERNAL_IP4} 127.0.0.1 $SERVER_PORT" >>"${APACHE_INTERNALS_CONFIG_FILE}"
# Append Apache macro invocation for /internal-server-status based on mod_status and INSTANCE_DNS to "${APACHE_INTERNALS_CONFIG_FILE}"
echo "Appending macro usage for $INSTANCE_DNS/internal-server-status URL for mod_status based Apache monitoring to "${APACHE_INTERNALS_CONFIG_FILE}" >>/var/log/sailing.out
echo "Appending macro usage for $INSTANCE_DNS/internal-server-status URL for mod_status based Apache monitoring to ${APACHE_INTERNALS_CONFIG_FILE}" >>/var/log/sailing.err
echo "## SERVER STATUS" >>"${APACHE_INTERNALS_CONFIG_FILE}"
echo "Use Status $INSTANCE_DNS internal-server-status" >>"${APACHE_INTERNALS_CONFIG_FILE}"
}
@@ -167,7 +168,7 @@ create_basic_httpd_config() {
stop_httpd() {
if [ -x /etc/init.d/httpd ]; then
service httpd stop
echo "Stopped httpd..." >>/var/log/sailing.out
echo "Stopped httpd..." >>/var/log/sailing.err
fi
}