2012年12月28日金曜日

OpenShiftのTomcat添付README(作成中)

OpenShiftのTomcatに付いていたREADME。
徐々に翻訳予定。


Repo layout
レポレイアウト
===========
webapps/ - location for built wars (Details below)
webapps/ - 構築されたWARファイルの配置場所(以下詳細)
src/ - Maven src structure
src/ - Mavenのソース構造
pom.xml - Maven build file
pom.xml - Mavenのビルドファイル
.openshift/ - location for openshift specific files
.openshift/ - openshiftの詳細ファイル配置場所
.openshift/config/ - location for configuration files such as standalone.xml (used to modify jboss config such as datasources)
.openshift/config/ - standalone.xmlなど設定ファイル配置場所 (データソースなどJBoss設定に使用)
ん?standalone.xmlなんか無いぞ?server.xmlなどtomcatの設定ファイルだぞ?
.openshift/action_hooks/pre_build - Script that gets run every git push before the build (on the CI system if available)
.openshift/action_hooks/pre_build - git pushビルドの前に実行されるスクリプト(もし有効であればCIシステム上で)
.openshift/action_hooks/build - Script that gets run every git push as part of the build process (on the CI system if available)
.openshift/action_hooks/build - git pushビルドプロセスの一部として実行されるスクリプト(もし有効であればCIシステム上で)
.openshift/action_hooks/deploy - Script that gets run every git push after build but before the app is restarted
.openshift/action_hooks/deploy - git pushビルド後毎に実行されるアプリが再起動される前に実行されるスクリプト
.openshift/action_hooks/post_deploy - Script that gets run every git push after the app is restarted
.openshift/action_hooks/post_deploy - アプリが再起動された後、git push毎に実行されるスクリプト
.openshift/action_hooks/pre_start_jbossews-1.0 - Script that gets run prior to starting EWS1.0
.openshift/action_hooks/pre_start_jbossews-1.0 - EWS1.0を開始する前に実行されるスクリプト
.openshift/action_hooks/post_start_jbossews-1.0 - Script that gets run after EWS1.0 is started
.openshift/action_hooks/post_start_jbossews-1.0 - EWS1.0開始後に実行されるスクリプト
.openshift/action_hooks/pre_stop_jbossews-1.0 - Script that gets run prior to stopping EWS1.0
.openshift/action_hooks/pre_stop_jbossews-1.0 - EWS1.0を停止する前に実行されるスクリプト
.openshift/action_hooks/post_stop_jbossews-1.0 - Script that gets run after EWS1.0 is stopped
.openshift/action_hooks/post_stop_jbossews-1.0 - EWS1.0停止後に実行されるスクリプト


Notes about layout
レイアウトについての注意事項
==================
Note: Every time you push, everything in your remote repo dir gets recreated
      please store long term items (like an sqlite database) in the OpenShift
      data directory, which will persist between pushes of your repo.
注意:あなたがpushをかける度に、あなたのリモート・レポ・ディレクトリ内全ては再作成を受けるので、OpenShiftデータ・ディレクトリには長期アイテム(sqliteデータベースのような)をストアしてください。そこはプッシュの間も持続されます。
      The OpenShift data directory is accessible relative to the remote repo
      directory (../data) or via an environment variable OPENSHIFT_DATA_DIR.
OpenShiftのdataディレクトリは、相対的なリモートレポ(../data)経由、又はOPENSHIFT_DATA_DIR環境変数を経由してアクセス可能です。


Details about layout and deployment options
レイアウトとデプロイメント・オプションの詳細
==================
There are two options for deploying content to the Tomcat Server within OpenShift.
OpenShiftのTomcatサーバーにコンテンツをデプロイするのに2つのオプションがある。 
Both options can be used together (i.e. build one archive from source and others pre-built)
どちらのオプションも一緒に使用される(すなわち、ソースと他のプレ・ビルドから一つのアーカイブがビルドされる)。

1) (Preferred) You can upload your content in a Maven src structure as is this sample project and on git push have the application built and deployed.
1) (好ましい方法)サンプルプロジェクトのようにMavenソース構造のコンテンツをアップロード可能であり、そしてgit pushでアプリケーションをビルドし、デプロイされる。
For this to work you'll need your pom.xml at the root of your repository and a maven-war-plugin like in this sample to move the output from the build to the webapps directory.
これが正常に機能するために、レポジトリルートにpom.xmlが必要で、サンプルのようなmaven-war-pluginがbuildからwebappsディレクトリへ出力するのに必要だろう。
By default the warName is ROOT within pom.xml.
デフォルトのWARファイル名は、pom.xmlの中にあるROOTである。
This will cause the webapp contents to be rendered at http://app_name-amespace.rhcloud.com/.
これはwebappコンテンツがhttp://app_name-amespace.rhcloud.com/で表示されるためである。
If you change the warName in pom.xml to app_name, your base url would then become http://app_name-namespace.rhcloud.com/app_name.
もしpom.xml中のwarNameをapp_nameに変えたなら、ベースURLはhttp://app_name-namespace.rhcloud.com/app_nameとなる。
Note: If you are building locally you'll also want to add any output wars under webapps
from the build to your .gitignore file.
注意:もしローカルでビルドしているのなら、幾つかwebapps下に出力したwarファイルを、ビルドから.gitignoreファイルまで追加を望むでしょう。
Note: If you are running scaled EWS1.0 then you need an application deployed to the root context (i.e. http://app_name-namespace.rhcloud.com/) for the HAProxy load-balancer to recognize that the EWS1.0 instance is active.
注意:もし貴方がスケールされたEWS1.0を実行しているなら、EWS1.0インスタンスがアクティブであることを認識する為に、HAProxyロードバランサーの為に、ルートコンテキストへのアプリケーション配備が必要です。
or
もしくは
2) You can git push pre-built wars into webapps/.
2) webappsフォルダにプレビルドのwarをgit pushすることができる。
To do this with the default repo you'll want to first run 'git rm -r src/ pom.xml' from the root of your repo.
デフォルトのレポでこれを行うには、あなたのレポのルートから'git rm -r src/ pom.xml'を最初に実行しようと望むだろう。
Basic workflows for deploying pre-built content (each operation will require associated git add/commit/push operations to take effect):
ビルド前コンテンツをデプロイするための基本ワークフロー(各オペレーションは有効となるためにgit add/commit/push操作に関連が必要となる):

A) Add new zipped content and deploy it:
A)新規ZIPコンテンツを追加し、それをデプロイする:

1. cp target/example.war webapps/

B) Undeploy currently deployed content:
B)現在デプロイされたコンテンツをアンデプロイする:

1. git rm webapps/example.war

C) Replace currently deployed zipped content with a new version and deploy it:
C)現在デプロイされたZIPコンテンツを新バージョンに置き換え、それをデプロイする:

1. cp target/example.war webapps/

Note: You can get the information in the uri above from running 'rhc domain show'
注意:あなたは'rhc domain show'実行結果のURIの中で、情報を入手可能である。

If you have already committed large files to your git repo, you rewrite or reset the history of those files in git to an earlier point in time and then 'git push --force' to apply those changes on the remote OpenShift server.
あなたがGitレポに、既にコミットされた大きなファイルを有しているのなら、あなたは上書き又はそれらのファイルの履歴をgit以前の時点にリセットし、次に'git push --force'を適用してリモートOpenShiftサーバー上でこれらを変更して欲しい。
A git gc on the remote OpenShift repo can be forced with (Note: tidy also does other cleanup including clearing log files and tmp dirs):
リモートOpenShift上のgit gcは、強制させることもできる(注意:)
rhc app tidy -a appname


Whether you choose option 1) or 2) the end result will be the application
deployed into the webapps directory. The webapps directory in the
Tomcat distribution is the location end users can place
their deployment content (e.g. war, ear, jar, sar files) to have it
automatically deployed into the server runtime.

Environment Variables
=====================

OpenShift provides several environment variables to reference for ease
of use.  The following list are some common variables but far from exhaustive:

    System.getenv("OPENSHIFT_APP_NAME")  - Application name
    System.getenv("OPENSHIFT_DATA_DIR")  - For persistent storage (between pushes)
    System.getenv("OPENSHIFT_TMP_DIR")   - Temp storage (unmodified files deleted after 10 days)
    System.getenv("OPENSHIFT_INTERNAL_IP")  - The IP address used to bind EWS1.0

When embedding a database using 'rhc app cartridge add', you can reference environment
variables for username, host and password. For example, when embedding MySQL 5.1, the
following variables will be available:

    System.getenv("OPENSHIFT_MYSQL_DB_HOST")      - DB host
    System.getenv("OPENSHIFT_MYSQL_DB_PORT")      - DB Port
    System.getenv("OPENSHIFT_MYSQL_DB_USERNAME")  - DB Username
    System.getenv("OPENSHIFT_MYSQL_DB_PASSWORD")  - DB Password

To get a full list of environment variables, simply add a line in your
.openshift/action_hooks/build script that says "export" and push.