metasearch運用手順

MetasearchDBのアップデート方法

#yoshitakeユーザなどで@m128m
sudo systemctl stop metasearch

#user2で
cd /suikou/download9-v251/metasearch/metasearch
git pull
npm install
cd metasearch/data
ln -s /suikou/download9-v251/metasearch/metasearch_dev/metasearch/data/* .

#yoshitakeユーザなどで
sudo systemctl start metasearch

以下は古い情報

ローカルでの開発後のテスト環境でのテスト、及び本番環境へのデプロイは以下の手順で行う。

以下は容量が小さいファイルの更新手順(100Mb以下のファイルの更新手順)

  1. ローカル環境にm50v251n3サーバ上の/home/yoshitake/metasearch_repo をリモートリポジトリとして追加する。

    - linuxターミナル上なら例えば、

    mkdir /tmp/mylocalrepo; cd /tmp/mylocalrepo/; git init; git remote add metarepo /home/yoshitake/metasearch_repo/; git pull metarepo master;

    ユーザ名も変更しておく。

    git config --local user.name "Yoshitake"; git config --local user.email "akyoshita@g.ecc.u-tokyo.ac.jp"

  2. ローカル環境で開発が完了したら、上記リポジトリにPushする。(この時自動的にテスト環境へのデプロイとGithubへのPushが行われる)

    - linuxターミナル上なら例えば、

    cd /tmp/mylocalrepo/metasearch/script/; ...なにかファイルを編集...; git commit -m "コメントを書くこと"; git push metarepo

  3. (npmモジュールの更新などを行った場合のみ) cd /home/yoshitake/metasearch_dev/metasearch に移動し、npm install で依存関係を解消する。
  4. cd /home/yoshitake/metasearch_dev/metasearch に移動し、npm start でテスト環境のアプリケーションを起動する。
  5. https://meta.fs.a.u-tokyo.ac.jp/metasearch_dev/ にアクセスし、問題なく動作するかを確認する。
  1. まだ本番環境を構築していないときは、

    mkdir /home/yoshitake/metasearch_test; cd /home/yoshitake/metasearch_test; git init; git remote add origin /home/yoshitake/metasearch_repo;

    を実行しておく。

  2. また、既に実行されているMetaSearchDBを停止させておく。forever listで出てくるのはMetaSearchDBやMitoSearchがあるので、どれがMetaSearchDBかを調べるため、pidの数字に対してpwdx <pid>とpwdxを使って実行ディレクトリを調べて、/home/yoshitake/metasearch/metasearchで実行されているプロセスのuid前の数字(0,1,2,…程度の値)を割り出す。それからforever stop <uid前の数字>で停止できる。停止まで数分程度かかる様子。
  3. 本番環境に移動する。cd /home/yoshitake/metasearch/metasearch
  4. リモートリポジトリ(/home/yoshitake/metasearch_repo)から、最新版をPull。git pull (初回構築時はgit pull origin masterの必要あり)
  5. 本ページ下部のconfigファイル編集を行う。
  6. もし新規に構築した場合、scriptフォルダの中のファイルがいくつか不足しているので、*.sifファイルコピーや、db*へのシンボリックリンク作成などを、他の実行環境を見て適宜行う。
  7. git pullが上手くできない場合(基本的にデプロイ後スクリプトの修正が入るとpullできない)、git fetch origin master でリモートの最新の状態を取り込んだ後、git reset --hard origin/master でリセットをおこなう。script内の変更があった場合、scriptに移動しchmod 755 *で実行権限を付与する。
  8. アプリケーションのあるディレクトリに移動。cd /home/yoshitake/metasearch/metasearch その後、依存関係を解消する。npm install
  9. forever start --workingDir /home/yoshitake/metasearch/metasearch/ -c "npm start" ./ で再起動。
    ※startが上手くいかない時は取り敢えずPCをrebootした方が楽。foreverを再起動してもすぐ停止してしまうことがある(forever stopしてもポートが占有されている?)
  10. これでデプロイ完了。

ローカル環境、テスト環境(/home/yoshitake/metasearch_dev/metasearch)、本番環境(/home/yoshitake/metasearch/metasearch)にそれぞれ手動でコピーする。

InputファイルのDB更新の際はmetasearch_exec.sh上のdbPath変数を変更してあげればよい(絶対パス)

Githubに載せることができないアカウント情報や、本番環境とテスト環境で異なるパラメータを使用する際の参照先として、config/config.jsonを作成した。

テスト環境では/home/yoshitake/metasearch_dev/metasearch/config/config.json

本番環境では/home/yoshitake/metasearch/metasearch/config/config.json

にconfigファイルを配置している。

編集が必要な際はこのファイルをviなどで編集すれば良い。

configファイルの具体的な構造は以下の通り

{
  "account": {
    "addr": "suikou_metasearch@yahoo.co.jp",
    "pass": "uE7dOLCbHi"
  },
  "port": 3000,
  "url": "https://meta.fs.a.u-tokyo.ac.jp/metasearch"
}

以下、各項目の詳細。必要があれば各項目を編集 or 追加

  • account:Yahooアカウントの情報
  • addr:Yahooメールアドレス
  • pass:Yahooアカウントのパスワード
  • port:Node.jsアプリで使用するポート番号
  • url:metasearchのURL(メール通知で使用する)
  • metasearch運用手順.1708960423.txt.gz
  • 最終更新: 2024/02/26 15:13
  • by suikou