EWD (Enterprise Web Developer)は、高度なWebアプリケーション開発技術とAjaxフレームワークです。 EWDは、M/Gateway Developmentsが開発している、GNU Affero General Public License Ver3 のオープンソースソフトウェアです。
Git Hub リポジトリ https://github.com/robtweed/EWD でメンテナンスされています。
この章では、EWDインストールからapache設定までを解説します。 EWDルーチン、関連ライブラリのインストールとEWD設定は、次の EWD設定とテストの章で解説します。
最新バージョンのGT.Mがインストールされ、適切な環境変数が定義されていることが必要です。
GitのEWDリポジトリからEWDパッケージをダウンロードしますので、git-core をインストールしておきます。 (オフラインの場合は、EWDリポジトリから。zip形式ファイルをダウンロードします)
sudo apt-get install git-core
$DBINST/srcディレクトリに、git経由でEWDをダウンロードします。
cd $DBINST/src
git clone git://github.com/robtweed/EWD.git
ダウンロードしたEWDは、以下のような構成になっています。
$DBINST/src/EWD
|-- _zewd*.m EWD GT.M用ライブラリルーチン
.
.
|-- docs
|-- ewdApps
|-- ewdMgr
|-- iWDApps
|-- iwd
|-- m_apache MGWSIルーチンとapacheモジュール
|-- node
|-- openMDWS
|-- printDiv
`-- python
EWDに必要なものは、_zewd*.m(EWD GT.M用ライブラリルーチン)とm_apache(MGWSIルーチンとapacheモジュール)です。
EWD構築用の仮の環境変数設定ファイル env.conf を、$DBINST/etc に作ります。 GT.Mのインストールと設定で作った
$DBINST/etc/env.conf (仮設定)
export DBINST=/home/mta
export GTMVER="V6.0-003_x8664"
export PATH=$DBINST/lib/fwslc/inst.bin:$DBINST/lib/gtm:/opt/lsb-gtm/$GTMVER/utf8:$PATH
export gtm_icu_version=4.2
export gtm_chset="UTF-8"
export LANG="ja_JP.UTF-8"
export gtm_dist=/opt/lsb-gtm/$GTMVER/utf8
export gtm_log=$DBINST/log
export gtmgbldir=$DBINST/g/db.gld
export gtmroutines="$DBINST/r/$GTMVER($DBINST/r)
export gtmroutines="$gtmroutines $DBINST/routines/test/$GTMVER($DBINST/routines/test)
#export gtmroutines="$gtmroutines $DBINST/lib/mgwsi/$GTMVER($DBINST/lib/mgwsi)"
# mgwsiの設定でコメントアウトします
#export gtmroutines="$gtmroutines $DBINST/lib/ewd/routines/$GTMVER($DBINST/lib/ewd/routines)"
# ewd のルーチン設定でコメントアウトします
#export gtmroutines="$gtmroutines $DBINST/www/r/$GTMVER($DBINST/www/r)
# EWDを実行するルーチンの設定でコメントアウトします
export gtmroutines="$gtmroutines $gtm_dist"
export gtmroutines="$gtmroutines /opt/lsb-gtm/$GTMVER/libgtmshr.so /opt/lsb-gtm/$GTMVER/libgtmutil.so"
export gtm_prompt="GTM>"
# Define aliases
alias dse="$gtm_dist/dse"
alias gde="$gtm_dist/mumps -run GDE"
alias gtm="$gtm_dist/gtm"
ログインプロファイル(.bash_profile)に、env.confを実行する(source)記述を追加します。
# .bash_profile
#
# GT.M environment
source $HOME/etc/env.conf
MGWSIはApacheからのリクエストをリッスンするGT.MのTCPリスナーです。 $gtmroutinesに、MGWSI用のルーチンディレクトリを追加します (あるいは、既存のgtmroutinesのディレクトリで使用することもできます)
MGWSIルーチン用のディレクトリを作成し、$DBINST/libに、そのシンボリックリンクを作成。
mkdir -p /opt/lsb-mgateway/ewd/current/m_apache
mkdir -p /opt/lsb-mgateway/ewd/current/m_apache/V6.0-003_x8664
cp $DBINST/src/EWD/m_apache/*.m /opt/lsb-mgateway/ewd/current/m_apache
mkdir -p $DBINST/lib
cd $DBINST/lib
ln -s /opt/lsb-mgateway/ewd/current ewd
ln -s ./ewd/m_apache
環境変数 gtmroutines にMGWSIルーチン用のディレクトリを登録 (上記の環境設定ファイルenv.confの該当部分をコメントアウト)
export gtmroutines="$gtmroutines $DBINST/lib/mgwsi/$GTMVER($DBINST/lib/mgwsi)"
source $DBINST/etc/env.conf
MGWSIルーチンを確認します。
CentOS6:~/ $ mumps -dir
GTM>d ^%RD
Routine directory
Routine: %ZM*
%ZMGWSI %ZMGWSIS
Total of 2 routines.
GTM>H
%ZMGWSISをテスト動作します。
CentOS6:~/ $ mumps -r INETD^%ZMGWSIS
;;; CTRL_C で停止します。
%GTM-I-CTRLC, CTRL_C encountered
GTM>ZSHOW
CHILD3+5^%ZMGWSIS (Direct mode)
XINETD+2^%ZMGWSIS
GTM>H
Fourth Watch Software LC ライブラリは、EWDのm_apacheモジュールとシェルスクリプトのライブラリです。
fwslc EWDサポートライブラリ(lsb-fwslc)をダウンロードし展開し、ファイルをコピーし、 $DBINST/lib にシンボリックリンクを作成します。
cd $DBINST/src
tar xzovf lsb-fwslc20100820.tar.gz
展開後の構成
lsb-fwslc20100820
|-- http.etc
| |-- ewd-proxy Setup for EWD proxy allowing https
| |-- ewd-virtualhosts
| `-- mgwsi.load http.conf用
|-- inst.bin
| |-- cprs.sh
| |-- gtm_backup.sh
| |-- gtm_rundown.sh
| |-- gtm_start.sh
| |-- mgwsi.sh Start the M/Gateway Interface
| `-- voe
`-- inst.etc
`-- mgwsi-xinetd.conf xinetd configuration for MGWSI
ライブラリ用のディレクトリを作成し、コピーします。
mkdir -p /opt/lsb-fwslc/20100820
cp -r $DBINST/src/lsb-fwslc20100820/* /opt/lsb-fwslc/20100820
$DBINST/lib にシンボリックリンクを作成します。
cd $DBINST/lib
ln -s /opt/lsb-fwslc/20100820 fwslc
xinetからM/Gateway Interface を起動する mgwsi.sh を編集しテストします。
vi $DBINST/lib/fwslc/inst.bin/mgwsi.sh
編集 mgwsi.sh
# Start the M/Gateway Interface
cd /home/gtm
source etc/env.conf
if [ ! -d log ] ; then
mkdir log
fi
LOG=log/mgwsi.log
env >> ${LOG} 2>&1
echo "$0 entry: `date`" >> ${LOG}
echo "mumps -r INETD^%ZMGWSIS" >> ${LOG}
mumps -r INETD^%ZMGWSIS
# >> ${LOG} 2>&1
echo "$0 exit: `date`" >> ${LOG}
# $RCSfile: mgwsi.sh,v $
mgwsi.sh に、実行権限を付与します。
chmod +x $DBINST/lib/fwslc/inst.bin/mgwsi.sh
mgwsi.sh をテストします。
CentOS6:~/ $ $DBINST/lib/fwslc/inst.bin/mgwsi.sh
;;; CTRL_C で停止します。
%GTM-I-CTRLC, CTRL_C encountered
GTM>zshow
CHILD3+5^%ZMGWSIS (Direct mode)
XINETD+2^%ZMGWSIS
GTM>h
mgwsi用のサービス名とポート番号を /etc/services に記述します。
sudo vi /etc/services
追加します。
mgwsi 7040/tcp # Service for MGWSI clients
mgwsi-xinetd.conf は、xinetd 経由で、mgwsi.sh を起動するための設定ファイルです。
vi $DBINST/lib/fwslc/inst.etc/mgwsi-xinetd.conf
編集 mgwsi-xinetd.conf
# Configuration for M/Gateway MGWSI.
service mgwsi
{
port = 7040
id = mgwsi
socket_type = stream
protocol = tcp
type = UNLISTED
user = mta
server = /bin/bash
server_args = /opt/lsb-fwslc/20100820/inst.bin/mgwsi.sh
wait = no
disable = no
per_source = UNLIMITED
instances = UNLIMITED
}
# $RCSfile: mgwsi-xinetd.conf,v $
/etc/xinetd.d に、mgwsi-xinetd.conf へのシンボリックリンクを作ります。
cd /etc/xinetd.d
sudo ln -s $DBINST/lib/fwslc/inst.etc/mgwsi-xinetd.conf mgwsi
xinetdのデバッグモードで、mgwsi-xinetd.conf をテストします。
cd /etc/xinetd.d
sudo /etc/init.d/xinetd stop
sudo xinetd -d &
[2] 10521
...
Service configuration: mgwsi
id = mgwsi
flags = IPv4
type = UNLISTED
socket_type = strea
...
11/5/23@10:41:33: DEBUG: 10521 {cnf_start_services} Started service: mgwsi
...
...
この状態から、telnetで、ポート7040に入ります。
$ telnet localhost 7041
Trying ::1...
Trying 127.0.0.1...
11/5/23@10:41:52: DEBUG: 10521 {main_loop} select returned 1
Connected to localhost.
Escape character is '^]'.
11/5/23@10:41:52: DEBUG: 10521 {server_start} Starting service mgwsi
11/5/23@10:41:52: DEBUG: 10521 {main_loop} active_services = 8
11/5/23@10:41:52: DEBUG: 10523 {exec_server} duping 14
ここで、CTL + ] をタイプし、telnetを終了します。
telnet> quit
Connection closed.
11/5/23@10:41:57: DEBUG: 10521 {main_loop} active_services = 8
11/5/23@10:41:57: DEBUG: 10521 {main_loop} select returned 1
11/5/23@10:41:57: DEBUG: 10521 {check_pipe} Got signal 17 (Child exited)
11/5/23@10:41:57: DEBUG: 10521 {child_exit} waitpid returned = 10523
11/5/23@10:41:57: DEBUG: 10521 {server_end} mgwsi server 10523 exited
11/5/23@10:41:57: INFO: 10521 {conn_free} freeing connection
11/5/23@10:41:57: DEBUG: 10521 {child_exit} waitpid returned = -1
11/5/23@10:41:57: DEBUG: 10521 {main_loop} active_services = 8
CTL + C で、デバッグモードのxinetd を終了します。
テストが完了したら、xinetd を通常のデーモンモードで起動しておきます。
cd /etc/xinetd.d
sudo /etc/init.d/xinetd start
m_apacheは、Webサーバ apacheのMGWSI用モジュールです。 m_apacheは、HTTP経由でのEWDリクエストを、xinetd で起動し常駐している%ZMGWSIと通信するゲートウェイです。
apacheのapxsコマンドで、モジュールファイル m_apache22.so をビルドします。 コンパイルには、gcc, httpd-devel, openssl-devel が必要です。
EWDのm_apacheソースディレクトリに移動
cd $DBINST/src/EWD/m_apache
apxsでモジュールを自動コンパイルします。apxsでは、ビルドできた m_apache22.so モジュールを自動的に httpd/modules ディレクトリにインストールし、/etc/httpd/conf/httpd.conf にモジュール組み込みの記述も 自動的に行ってくれます。
apxs -i -a -I/usr/include/openssl/ -n m_apache22 -o m_apache22.so -c m_apache.c
もし、コンパイルエラーが出たり、EWD動作で m_apacheに不具合がある場合は、手動でモジュールをコンパイルし、 手動で、httpd/modules ディレクトリにコピーし、手動で /etc/httpd/conf/httpd.conf にモジュール組み込みを記述してください。
gcc -fPIC -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wformat-security -fno-strict-aliasing -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/httpd -I/usr/include/apr-1 -I/usr/include/apr-1 -I/usr/include/openssl/ -c -o m_apache.obj m_apache.c
gcc -shared -rdynamic -o m_apache22.so m_apache.obj
apache2の基本設定ファイル /etc/httpd/conf/httpd.conf に、m_apacheの設定を記述します。
LoadModule m_apache_module /usr/lib64/httpd/modules/m_apache.so
#
# m_apache http enviroment
SetEnv MGWSI_M_FUNCTION ENTRY^%HTT
EWD用のApache設定ファイル $DBINST/fwslc/http.etc/httpd.conf を編集し、
/opt/lsb-fwslc/20100820/http.etc/httpd.conf
# M/Gateway EWD
<Location "/mta">
SetEnv MGWSI_PORT 7040 # xinetdで起動するMGWSIのポート
SetEnv MGWSI_M_UCI /home/gtm/g/db.gld # グローバル ディレクトリ
SetEnv MGWSI_M_FUNCTION runPage^%zewdGTMRuntime # 起動させる MGWSIのRuntime
</Location>
Alias /mta /home/gtm/www # /mtaのロケーションのエイリアス
# $RCSfile: httpd.conf,v $
/etc/httpd/conf.d の下にシンボリックリンクを作成します。
cd /etc/httpd/conf.d
sudo ln -s /opt/lsb-fwslc/20100820/http.etc/httpd.conf ewd.conf
apacheの再起動
$ sudo service httpd restart
httpd を停止中: [ OK ]
httpd を起動中: [ OK ]
$