Skip to content

Commit

Permalink
copy files
Browse files Browse the repository at this point in the history
  • Loading branch information
Takuya Murakami committed Nov 19, 2018
1 parent 39e9e2c commit 7cb46e0
Show file tree
Hide file tree
Showing 12 changed files with 696 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
91 changes: 91 additions & 0 deletions both/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/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=
if [ -n "$TOMCAT_PROXY_PORT" ]; then
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
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
fi

# tomcat 起動 (foreground)
/opt/tomcat/bin/catalina.sh run
11 changes: 11 additions & 0 deletions both/logback.template.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ログレベル
logback.level=%LOG_LEVEL%

# ログ出力タイプ
logback.types=%LOG_TYPES%
# ログ出力ディレクトリ
logback.logdir=/var/log/baas

# fluentd サーバ
#logback.fluent.host=%LOG_FLUENT_HOST%
#logback.fluent.port=%LOG_FLUENT_PORT%
72 changes: 72 additions & 0 deletions both/properties.template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?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>

</properties>
174 changes: 174 additions & 0 deletions both/server.template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>

<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">

<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->


<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
maxConnections="%TOMCAT_MAX_CONNECTIONS%"
maxThreads="%TOMCAT_MAX_THREADS%"
redirectPort="8443"
scheme="%TOMCAT_SCHEME%"
secure="%TOMCAT_SECURE%"
%TOMCAT_CONN_OTHER_CFGS%
/>
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
This connector uses the NIO implementation. The default
SSLImplementation will depend on the presence of the APR/native
library and the useOpenSSL attribute of the
AprLifecycleListener.
Either JSSE or OpenSSL style configuration may be used regardless of
the SSLImplementation selected. JSSE style configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true">
<SSLHostConfig>
<Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
type="RSA" />
</SSLHostConfig>
</Connector>
-->
<!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
This connector uses the APR/native implementation which always uses
OpenSSL for TLS.
Either JSSE or OpenSSL style configuration may be used. OpenSSL style
configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true" >
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
certificateFile="conf/localhost-rsa-cert.pem"
certificateChainFile="conf/localhost-rsa-chain.pem"
type="RSA" />
</SSLHostConfig>
</Connector>
-->

<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
-->

<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">

<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->

<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">

<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->

<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" />

</Host>
</Engine>
</Service>
</Server>
Loading

0 comments on commit 7cb46e0

Please sign in to comment.