-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve: use envsubst, add URL parameters.
- Loading branch information
Takuya Murakami
committed
Nov 20, 2018
1 parent
adf5799
commit 0e73354
Showing
4 changed files
with
66 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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#<!-- <entry key="amqp.addrs"></entry> -->#<entry key="amqp.addrs">%AMQP_ADDR%</entry>#' \ | ||
| sed 's#<!-- <entry key="amqp.username"></entry> -->#<entry key="amqp.username">%AMQP_USERNAME%</entry>#' \ | ||
| sed 's#<!-- <entry key="amqp.password"></entry> -->#<entry key="amqp.password">%AMQP_PASSWORD%</entry>#' \ | ||
| sed 's#<!-- <entry key="amqp.vhost"></entry> -->#<entry key="amqp.vhost">%AMQP_VHOST%</entry>#' \ | ||
| 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#<!-- <entry key="amqp.uri"></entry> -->#<entry key="amqp.uri">%AMQP_URI%</entry>#' \ | ||
| 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> | ||
<!-- | ||
プロパティ設定 XML ファイル。 | ||
本ファイルは、BaaSの設定を行うためのものである。 | ||
以下いずれかのディレクトリに production.xml, development.xml, test.xml の名称で配置する。 | ||
複数置いた場合は、下のものが優先される。 | ||
1) /etc/baas/ | ||
2) c:/NEC/BaaS/etc/ (Windows) | ||
3) ~/.baas/ | ||
4) [デプロイディレクトリ]/WEB-INF/classes/ (クラスパス) | ||
なお設定値はサーバ起動時のシステムプロパティや環境変数、およびデベロッパーコンソール | ||
でも設定できる。複数設定した場合は、下のものが優先される。 | ||
1) XMLファイル | ||
2) 環境変数 | ||
3) システムプロパティ | ||
4) デベロッパーコンソールのシステム設定値 | ||
なお、Spring のプロファイル(production/development/test)の切り替えはここではできない。 | ||
WARファイル内の web.xml ファイルを変更するか、 | ||
JVM オプション -Dspring.profiles.active で起動時に指定する。 | ||
logback の設定は、このファイルではなく logback.xml ファイルで行う。 | ||
--> | ||
<properties> | ||
<!-- APIサーバ ベースURI デフォルト設定 --> | ||
<!-- <entry key="api.baseUrl">http://baas.example.com/api</entry> --> | ||
|
||
<!-- APIサーバ 内部向けベースURI デフォルト設定 --> | ||
<!-- 省略時は api.baseUrl の値が使用される --> | ||
<!-- <entry key="api.internalBaseUrl"></entry> --> | ||
|
||
<!-- Consoleサーバ ベースURI デフォルト設定 --> | ||
<!-- 注: デベロッパーコンソール システム設定の値のほうが優先される --> | ||
<!-- <entry key="console.baseUrl">http://baas.example.com/console</entry> --> | ||
|
||
<!-- | ||
MongoDB 設定 | ||
--> | ||
<!-- MongoDB サーバ --> | ||
<entry key="mongo.servers">%MONGO_SERVERS%</entry> | ||
<!-- レプリカセットを使う場合は、カンマで区切って指定(3台以上) --> | ||
<!-- <entry key="mongo.servers">localhost:27017,localhost:27018,localhost:27019</entry> --> | ||
|
||
<!-- MongoDB認証ユーザ名 --> | ||
<entry key="mongo.username">%MONGO_USERNAME%</entry> | ||
<!-- MongoDB認証パスワード --> | ||
<entry key="mongo.password">%MONGO_PASSWORD%</entry> | ||
|
||
<!-- MongoDB ホスト当たり最大コネクション数 --> | ||
<entry key="mongo.maxConnectionsPerHost">%MONGO_MAX_CONNECTIONS_PER_HOST%</entry> | ||
|
||
|
||
<!-- | ||
AMQP サーバ設定 (SSE Push/カスタムロジック に必要)。 | ||
amqp.{addrs,username,password,vhost} を設定する、amqp.uri を設定するか、いずれか選択。 | ||
両方設定した場合は前者(addrs,...)が優先される。 | ||
--> | ||
<!-- <entry key="amqp.addrs"></entry> --> | ||
<!-- <entry key="amqp.username"></entry> --> | ||
<!-- <entry key="amqp.password"></entry> --> | ||
<!-- <entry key="amqp.vhost"></entry> --> | ||
<!-- <entry key="amqp.uri"></entry> --> | ||
|
||
<!-- APIカウント対象外キー : サーバマネージャ側と設定をあわせること --> | ||
<entry key="system.noChargeKey">%SYSTEM_NO_CHARGE_KEY%</entry> | ||
|
||
<entry key="api.baseUrl">$API_BASE_URL</entry> | ||
<entry key="api.internalBaseUrl">$API_INTERNAL_BASE_URL</entry> | ||
<entry key="console.baseUrl">$CONSOLE_BASE_URL</entry> | ||
|
||
<entry key="mongo.servers">$MONGO_SERVERS</entry> | ||
<entry key="mongo.username">$MONGO_USERNAME</entry> | ||
<entry key="mongo.password">$MONGO_PASSWORD</entry> | ||
<entry key="mongo.maxConnectionsPerHost">$MONGO_MAX_CONNECTIONS_PER_HOST</entry> | ||
|
||
<entry key="amqp.addrs">$AMQP_ADDR</entry> | ||
<entry key="amqp.username">$AMQP_USERNAME</entry> | ||
<entry key="amqp.password">$AMQP_PASSWORD</entry> | ||
<entry key="amqp.vhost">$AMQP_VHOST</entry> | ||
<entry key="amqp.uri">$AMQP_UI</entry> | ||
|
||
<entry key="system.noChargeKey">$SYSTEM_NO_CHARGE_KEY</entry> | ||
</properties> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters