diff --git a/bootstrap.sh b/bootstrap.sh index 15d1499..25e7606 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,91 +1,54 @@ #!/bin/sh # 環境変数 -MONGO_SERVERS=${MONGO_SERVERS:-127.0.0.1:27017} -MONGO_USERNAME=${MONGO_USERNAME:-} -MONGO_PASSWORD=${MONGO_PASSWORD:-} -MONGO_MAX_CONNECTIONS_PER_HOST=${MONGO_MAX_CONNECTIONS_PER_HOST:-200} -AMQP_ADDR=${AMQP_ADDR:-} -AMQP_USERNAME=${AMQP_USERNAME:-} -AMQP_PASSWORD=${AMQP_PASSWORD:-} -AMQP_VHOST=${AMQP_VHOST:-} -AMQP_URI=${AMQP_URI:-} -SYSTEM_NO_CHARGE_KEY=${SYSTEM_NO_CHARGE_KEY:-tC0br8ciFAZmYdUHfS1JeJy4c} -LOG_LEVEL=${LOG_LEVEL:-INFO} -LOG_FLUENT_HOST=${LOG_FLUENT_HOST:-} -LOG_FLUENT_PORT=${LOG_FLUENT_PORT:-24224} -TOMCAT_MAX_THREADS=${TOMCAT_MAX_THREADS:-2000} -TOMCAT_MAX_CONNECTIONS=${TOMCAT_MAX_CONNECTIONS:-2000} -TOMCAT_SCHEME=${TOMCAT_SCHEME:-http} -TOMCAT_SECURE=${TOMCAT_SECURE:-false} -TOMCAT_PROXY_PORT=${TOMCAT_PROXY_PORT:-} - -TOMCAT_CONN_OTHER_CFGS= +export API_BASE_URL=${API_BASE_URL:-http://localhost:8080/api} +export API_INTERNAL_BASE_URL=${API_INTERNAL_BASE_URL:-} +export CONSOLE_BASE_URL=${CONSOLE_BASE_URL:-http://localhost:8080/console} + +export MONGO_SERVERS=${MONGO_SERVERS:-127.0.0.1:27017} +export MONGO_USERNAME=${MONGO_USERNAME:-} +export MONGO_PASSWORD=${MONGO_PASSWORD:-} +export MONGO_MAX_CONNECTIONS_PER_HOST=${MONGO_MAX_CONNECTIONS_PER_HOST:-200} + +export AMQP_ADDR=${AMQP_ADDR:-} +export AMQP_USERNAME=${AMQP_USERNAME:-} +export AMQP_PASSWORD=${AMQP_PASSWORD:-} +export AMQP_VHOST=${AMQP_VHOST:-} +export AMQP_URI=${AMQP_URI:-} + +export SYSTEM_NO_CHARGE_KEY=${SYSTEM_NO_CHARGE_KEY:-tC0br8ciFAZmYdUHfS1JeJy4c} + +export LOG_LEVEL=${LOG_LEVEL:-INFO} +export LOG_FLUENT_HOST=${LOG_FLUENT_HOST:-} +export LOG_FLUENT_PORT=${LOG_FLUENT_PORT:-24224} + +export TOMCAT_MAX_THREADS=${TOMCAT_MAX_THREADS:-2000} +export TOMCAT_MAX_CONNECTIONS=${TOMCAT_MAX_CONNECTIONS:-2000} +export TOMCAT_SCHEME=${TOMCAT_SCHEME:-http} +export TOMCAT_SECURE=${TOMCAT_SECURE:-false} +export TOMCAT_PROXY_PORT=${TOMCAT_PROXY_PORT:-} + +export TOMCAT_CONN_OTHER_CFGS= if [ -n "$TOMCAT_PROXY_PORT" ]; then - TOMCAT_CONN_OTHER_CFGS="proxyPort=\"$TOMCAT_PROXY_PORT\"" + export TOMCAT_CONN_OTHER_CFGS="proxyPort=\"$TOMCAT_PROXY_PORT\"" fi -# Tomcat server.xml設定 -cat server.template.xml \ - | sed "s/%TOMCAT_MAX_THREADS%/$TOMCAT_MAX_THREADS/" \ - | sed "s/%TOMCAT_MAX_CONNECTIONS%/$TOMCAT_MAX_CONNECTIONS/" \ - | sed "s/%TOMCAT_SCHEME%/$TOMCAT_SCHEME/" \ - | sed "s/%TOMCAT_SECURE%/$TOMCAT_SECURE/" \ - | sed "s/%TOMCAT_CONN_OTHER_CFGS%/$TOMCAT_CONN_OTHER_CFGS/" \ - > /opt/tomcat/conf/server.xml - -# 設定ファイル生成 -if [ -n "$AMQP_ADDR" ]; then - echo "Set AMQP_ADDR" - cat /etc/baas/properties.template.xml \ - | sed 's##%AMQP_ADDR%#' \ - | sed 's##%AMQP_USERNAME%#' \ - | sed 's##%AMQP_PASSWORD%#' \ - | sed 's##%AMQP_VHOST%#' \ - | sed "s#%AMQP_ADDR%#$AMQP_ADDR#" \ - | sed "s#%AMQP_USERNAME%#$AMQP_USERNAME#" \ - | sed "s#%AMQP_PASSWORD%#$AMQP_PASSWORD#" \ - | sed "s#%AMQP_VHOST%#$AMQP_VHOST#" \ - > /tmp/properties.template.xml -elif [ -n "$AMQP_URI" ]; then - echo "Set AMQP_URI" - cat /etc/baas/properties.template.xml \ - | sed 's##%AMQP_URI%#' \ - | sed "s#%AMQP_URI%#$AMQP_URI#" \ - > /tmp/properties.template.xml -else - echo "Not set AMQP" - cp /etc/baas/properties.template.xml /tmp/properties.template.xml -fi - -cat /tmp/properties.template.xml \ - | sed "s#%MONGO_SERVERS%#$MONGO_SERVERS#" \ - | sed "s/%MONGO_USERNAME%/$MONGO_USERNAME/" \ - | sed "s/%MONGO_PASSWORD%/$MONGO_PASSWORD/" \ - | sed "s/%MONGO_MAX_CONNECTIONS_PER_HOST%/$MONGO_MAX_CONNECTIONS_PER_HOST/" \ - | sed "s/%SYSTEM_NO_CHARGE_KEY%/$SYSTEM_NO_CHARGE_KEY/" \ - > /etc/baas/development.xml - -# logback設定ファイル生成 -cat /etc/baas/logback.template.properties \ - | sed "s/%LOG_LEVEL%/$LOG_LEVEL/" \ - > /tmp/logback.template1.properties - if [ ! -n "$LOG_FLUENT_HOST" ]; then echo "Not set logback.fluent" - cat /tmp/logback.template1.properties \ - | sed "s/%LOG_TYPES%/STDOUT,FILE/" \ - > /etc/baas/logback.properties + export LOG_TYPES=STDOUT,FILE else echo "Set logback.fluent" - cat /tmp/logback.template1.properties \ - | sed "s/%LOG_TYPES%/STDOUT,FILE,FLUENT/" \ - | sed 's/#logback.fluent.host=/logback.fluent.host=/' \ - | sed 's/#logback.fluent.port=/logback.fluent.port=/' \ - | sed "s/%LOG_FLUENT_HOST%/$LOG_FLUENT_HOST/" \ - | sed "s/%LOG_FLUENT_PORT%/$LOG_FLUENT_PORT/" \ - > /etc/baas/logback.properties + export LOG_TYPES=STDOUT,FILE,FLUENT fi +# Tomcat server.xml設定 +cat server.template.xml | envsubst > /opt/tomcat/conf/server.xml + +# BaaS 設定ファイル生成 +cat /etc/baas/properties.template.xml | envsubst > /etc/baas/development.xml + +# logback設定ファイル生成 +cat /etc/baas/logback.template.properties | envsubst > /etc/baas/logback.properties + # tomcat 起動 (foreground) exec /opt/tomcat/bin/catalina.sh run diff --git a/logback.template.properties b/logback.template.properties index 18875cf..fee247f 100644 --- a/logback.template.properties +++ b/logback.template.properties @@ -1,11 +1,8 @@ -# ログレベル -logback.level=%LOG_LEVEL% +logback.level=$LOG_LEVEL + +logback.types=$LOG_TYPES -# ログ出力タイプ -logback.types=%LOG_TYPES% -# ログ出力ディレクトリ logback.logdir=/var/log/baas -# fluentd サーバ -#logback.fluent.host=%LOG_FLUENT_HOST% -#logback.fluent.port=%LOG_FLUENT_PORT% +logback.fluent.host=$LOG_FLUENT_HOST +logback.fluent.port=$LOG_FLUENT_PORT diff --git a/properties.template.xml b/properties.template.xml index ad103c3..c325ab0 100644 --- a/properties.template.xml +++ b/properties.template.xml @@ -1,72 +1,20 @@ - - - - - - - - - - - - - - - %MONGO_SERVERS% - - - - - %MONGO_USERNAME% - - %MONGO_PASSWORD% - - - %MONGO_MAX_CONNECTIONS_PER_HOST% - - - - - - - - - - - %SYSTEM_NO_CHARGE_KEY% - + $API_BASE_URL + $API_INTERNAL_BASE_URL + $CONSOLE_BASE_URL + + $MONGO_SERVERS + $MONGO_USERNAME + $MONGO_PASSWORD + $MONGO_MAX_CONNECTIONS_PER_HOST + + $AMQP_ADDR + $AMQP_USERNAME + $AMQP_PASSWORD + $AMQP_VHOST + $AMQP_UI + + $SYSTEM_NO_CHARGE_KEY diff --git a/server.template.xml b/server.template.xml index 9244d09..c8dd990 100644 --- a/server.template.xml +++ b/server.template.xml @@ -68,12 +68,12 @@ -->