Windows環境にSMTP環境を構築して、Node.jsからメールを配信できるようにする。

普段はLinuxで開発しているので、なんにも問題ないんですが、やはりWindowsさんは必要になって、
そこで、開発しないといけない機会もでてきます。。。Node.jsの環境をWindowsに作るで構築方法は記載しましたが、
Windowsには、SMTPが標準ではいません。(サーバ系OSを除く)
IISのオプション入れてとかいろいろ頑張ってましたが、Node.js気楽に構築できるのに、これは、ちょっと。。。って
なって行き着いた結果のご報告。結果から言うと、blackjumbodogを使用しました。

こちらで、環境設定して起動すると、問題なくメール配信のプログラムが作成できて、動作確認できますね!!

上記から、ダウンロードして、blackjumbodogをインストールします。

んで、blackjumbodogを起動して、以下の通りに設定をすると、メール配信ができるようになります。



開発者の方に感謝。

あとは、Nodemailerとか使って試してもらうとよいかと。。。

var mailer = require("nodemailer");

//SMTP(送信)サーバー接続のための設定
var setting = {}; // defaultを使用

// メールデータのセット
var mailOptions = {
    from: "test@example.com",           // 送信者
    to: "test@hogehoge.com",            // 送信先
    subject: "こんにちは",              // タイトル
    html: "<h1>(^^)/</h1>こんにちは〜。"// HTML body
}

// SMTP接続のプールを開きます smtpは再利用可能
var smtp = mailer.createTransport("SMTP", setting);

// 送信します
smtp.sendMail(mailOptions, function(error, response){
    if(error){
        console.log(error);
    }else{
        console.log("Message sent: " + response.message);
    }

    // smtpをもう使わないなら閉じる
    smtp.close();
});

blackjumbodock上のログと、配信されたことを確認してもらうと、環境構築完了!!

OmegaT ver3.0で機械翻訳「Microsoft translator」(無料プランで)を使用する方法

翻訳ツールのOmegaTの3.0がリリースされました。非常に嬉しいです。開発者、関係者の皆様に深く感謝します。

しばらくアップデートしてなかったので気づかなかったんですが、、3.0(前から?)で、
機械翻訳Microsoft translatorが追加されてました。

Googleさんは、translate APIが有料になってしまい、一般の方には、使用する敷居が高くなったのですが、
Microsoftさんは、20万字までの無料で翻訳APIが使用できます。英語スキルの低いワタクシには、使わない手はないですね!!

基本的には、自分への備忘録ということで。。。

とりあえず、「Windows Azure Marketplace」に登録する必要があります。
その手順は、こちらを参照してください。
翻訳Webサービス「Microsoft Translator」の概要と登録方法

必要なのは、登録後の上のタブの「マイアカウント」で表示される、
「プライマリ アカウント キー」と「顧客 ID」になります。

さぁ、準備はそろった!!と思うのですが、標準のドキュメントでは、Macのみの記載しか見当たりませんでした。

http://www.omegat.org/en/howtos/ms_translator_mac.html
(他の言語については、見つからなかった。)

Macは、エースが試してくれると思うのと、自分の環境がLinuxメイン(Winサブ)なので、そちらで調べてたら、
ビンゴなページがみつかりました。

http://www.proz.com/forum/omegat_support/241322-linux_omt_microsoft_translator_howto_needed.html

まぁ、そもそもGoogleAPIの使い方もわかってなかったんですが、すべて記載されてますね。

後は、これ通りやるだけです。

For Google, it's:
-Dgoogle.api.key=123456789abcdef

For Microsoft, it's
-Dmicrosoft.api.client_id=yourkey -Dmicrosoft.api.client_secret=123456789abcdef

So, basically, you can launch OmegaT with
java -jar -Dmicrosoft.api.client_id=yourkey -Dmicrosoft.api.client_secret=123456789abcdef OmegaT.jar
(everything on the same line)

さらに、スレッドで詳しく記載されてますね。

#!/bin/bash
# readlink follows any symbolic links to get the real file
REALOMEGATPATH=`dirname $(readlink -nf $0)`
"${REALOMEGATPATH}/jre/bin/java" -jar -Xmx512M -Dmicrosoft.api.client_id=Customer_ID -Dmicrosoft.api.client_secret=Primary_Account_Key "${REALOMEGATPATH}/OmegaT.jar" $*

where one should change Customer_ID and Primary_Account_Key which are personal Primary Account Key and Customer ID available at Azure Marketplace account page after registration

I am sure, if one need to do the same in Windows, one can edit the OmegaT.bat file and change its content to the following:

java -jar -Dmicrosoft.api.client_id=Customer_ID -Dmicrosoft.api.client_secret=Primary_Account_Key OmegaT.jar %* 

client_idが、日本語表示だと、「顧客ID」で、client_secretが「プライマリ アカウント キー」です。

上記では、400 Bad Requestが頻繁に表示されるため、アプリの登録を行なうことが良いと思います。

以下のURLを参照に、アプリの登録をします。
http://web.plus-idea.net/2012/08/api-microsoft-translator-java/

アプリケーションの登録ですが、基本は上記の通りですが、

  • 「クライアント ID」:自由
  • 「名前」:自由(例:OmegaTとか)
  • 「顧客の秘密」:自動生成
  • 「リダイレクト URI」:https://127.0.0.1

としています。

LinuxJREが付属しているOmegaT3.0の起動シェルは、以下になっていました。

#!/bin/bash
# readlink follows any symbolic links to get the real file
REALOMEGATPATH=`dirname "$(readlink -nf $0)"`
"${REALOMEGATPATH}/jre/bin/java" -jar -Xmx512M "${REALOMEGATPATH}/OmegaT.jar" $*

これを、上記アプリケーションで設定した内容にします。

#!/bin/bash
# readlink follows any symbolic links to get the real file
REALOMEGATPATH=`dirname "$(readlink -nf $0)"`
"${REALOMEGATPATH}/jre/bin/java" -jar -Xmx512M -Dmicrosoft.api.client_id=「クライアントID」 -Dmicrosoft.api.client_secret=「顧客の秘密」 "${REALOMEGATPATH}/OmegaT.jar" $*

※上記IDとキーは「」を除き、マイアカウントで表示される英数字を入力してください。

これで、OmegaTを起動します。
そして、「設定」-「機械翻訳」-「Microsoft Translator」を選択し、チェック状態にします。

で、翻訳文節で、「編集」-「機械翻訳に置換」(Ctrl-M)を使用すると、翻訳できました〜ヽ(゚∀゚)メ(゚∀゚)メ(゚∀゚)ノ

Windows環境では、batファイルに上記を追加するみたいなこと書いているんですが、batファイルはみあたりません。

上記ページのスレッドに以下が追記されていました。

Under Windows, the information is in OmegaT.l4J.ini

java -jar -Dmicrosoft.api.client_id=Customer_ID -Dmicrosoft.api.client_secret=Primary_Account_Key OmegaT.jar %*

There's no need to. Under Windows, one just edits OmegaT.l4J.ini, where the parameters are pre-configured:
# Microsoft Translator credentials
#-Dmicrosoft.api.client_id=xxxxx
#-Dmicrosoft.api.client_secret=xxxxx

It does work (I had to test it before releasing the version).

Didier

で、Windowsの方が、OmegaTがあるプログラムフォルダに、実際に「OmegaT.l4J.ini」というファイルがあり、
コメント化されているので、それを有効にしてしまえば、問題なく稼働できました。

つまるところWindowsのファイルが先に見つかっていれば悩まなかったと。。。

でも、これで便利になりますねー!!

pip install でダウンロード先サイトが落ちている場合の対応(mirrorを使ってpip でインストール)

今日、mercurialをインストールしたくて、pip install mercurialすると、いつまでたってもDownloadが開始されない。

と教えて頂きました。ありがとうございます。@flyingfoozy m(_ _)m

で、pipの使い方は、以下を参照していただくと、mirrorオプションとかがあるんですが、それ使ってもうまく行かない。。。

http://d.hatena.ne.jp/rudi/20110107/1294409385

助けてぇ〜 stackoverflow〜 ってことでさがしてみたら、あった。

http://stackoverflow.com/questions/10262306/how-to-point-pip-at-a-mercurial-branch

pip install https://bitbucket.org/mirror/mercurial/get/2.5.4.tar.gz

Rhodecodeでつくったvirturalenvとかだと、こんな感じ。

/var/www/rhodecode-venv/bin/pip install https://bitbucket.org/mirror/mercurial/get/2.5.4.tar.gz

これで良かったという、今後の自分へのメモ。

chefとcapistrano(Webistrano)っぽいのをPythonで(構築のみ)

Fabric+Webistranoっぽいのの構築したメモです。
rubyに入門しませんでしたm(_ _)m!!使用は、Pythonでいきたいなぁーっと。
pythonとshellの方が自分に実績があって、手に馴染むだけです。chefとcapistranoの方が、
現状では情報が多いので、誰得?になってしまうんだろうけど、自分用の記録。長編。。。

前は、phpでmakuoさん使ったデプロイツール作って使ってましたが(遠い目)今回は自前は辞め、
pythonで、chefっぽいものと、capistranoっぽいものを構築することが目的です。(capistranoはWebistranoを目標)

構築した環境は、Scientific Linux 6.4 x86_64です。
(インストール時のオプションは、Basic Serverで、カスタマイズで開発ツールを追加しています。)

■Fabricのインストール
Fabricはすでに有名ですね。FabricとCuisineの組み合わせが有名でchefの変わりとします。次の資料がまとまっています。


Facebookでは、chefがデプロイのようですが、instagramでは、デプロイはFabricみたいなので、
いいじゃん!!って言うようにしましょうw まぁ標準でPythonは入っていますので、導入は楽ですね。
rubyが好きな人や、そちらが手に馴染む人はそっちを選んだ方が賢いかもしれません。
というか、何度やっても同じ結果を求めるなら、chefのようなものを求めるべきな気もします。

今後、運用やら、Fabric周りの内容も記載していきたいと思います。

それでは、導入手順。SL6.4では、上記インストールオプションだと、最初から、
python-setuptools(easy_install)は導入されていました。virtualenvとかは今回切らずに、
system pythonを使うことにします。とりあえず、devel系の必要なパッケージを導入と、
なにはともあれまず、pipをインストールします。

yum install python-devel
yum install openssl-devel
easy_install pip

で、このあと、さぁ pip でFabricをインストールだぁー!!っと意気込むのですが、いきなりハマりまして。。
そのまま、pipでインストールしてFabric起動すると、こんなエラーがでちゃいます。

pip install Fabric
Downloading/unpacking Fabric
  Running setup.py egg_info for package Fabric
    warning: no previously-included files matching '*' found under directory 'docs/_build'
    warning: no previously-included files matching '*.pyc' found under directory 'tests'
    warning: no previously-included files matching '*.pyo' found under directory 'tests'
Requirement already satisfied (use --upgrade to upgrade): paramiko>=1.10.0 in /usr/lib/python2.6/site-packages (from Fabric)
Requirement already satisfied (use --upgrade to upgrade): pycrypto>=2.1,!=2.4 in /usr/lib64/python2.6/site-packages (from paramiko>=1.10.0->Fabric)
Installing collected packages: Fabric
  Running setup.py install for Fabric
    warning: no previously-included files matching '*' found under directory 'docs/_build'
    warning: no previously-included files matching '*.pyc' found under directory 'tests'
    warning: no previously-included files matching '*.pyo' found under directory 'tests'
    Installing fab script to /usr/bin
Successfully installed Fabric
Cleaning up...

でfabコマンド叩くと、エラーがつらずら〜ってでます。ドキュメント読むと、
Fabric1.6の導入では、PyCryptoが2.1以上を求められます。

pipで抜いてインストールし直してもなおらなくて、なんでかなぁーとかなやんでたら、
パッケージで、python-cryptoパッケージが実は入っていました。依存解消してくれないんですよね。。。

yum info python-crypto

Available Packages
Name        : python-crypto
Arch        : x86_64
Version     : 2.0.1
Release     : 22.el6
Size        : 157 k
Repo        : sl
Summary     : Cryptography library for Python
URL         : http://www.amk.ca/python/code/crypto.html
License     : Public Domain
Description : Python-crypto is a collection of both secure hash functions (such as MD5 and
            : SHA), and various encryption algorithms (AES, DES, RSA, ElGamal, etc.).

あぁー。。。気づくまでに時間かかりました。。。
なので、先にremoveしましょう。そして、依存解決してくれるだろうけど、PyCryptoをpipで先に導入しておきます。
(関連っぽい、paramikoもuninstallして入れなおしました)

yum remove python-crypto
pip uninstall paramiko
pip install pycrypto
pip install Fabric

これで、導入されました。

fab --version
Fabric 1.6.0
Paramiko 1.10.0

さて、これでchefっぽいことはできるので、次のwebistranoを構築に移ります。
いろいろ探したところ、これが唯一動いてしかも、良さげでした。

使用ソフトはauroraです。

Aurora is a web interface for deploy tool fabric created for remote deploying and "console scared" boys. Inspired by Webistrano.

とかΣd(゚∀゚d)イカス! ってなことで、Djangoで作られてますね。導入は簡単でした。
基本はREADME通りです。(vitualenvはしてないから無視)

git clone https://github.com/ak3n/aurora.git
cd aurora

して、README記載どおり、fab local_setupをします。途中、初回ログインようのアカウントを聞いてくるので、登録します。

fab local_setup
[localhost] local: pip install -r requirements.txt
Downloading/unpacking Django==1.4.1 (from -r requirements.txt (line 1))
  Downloading Django-1.4.1.tar.gz (7.7MB): 7.7MB downloaded
  Running setup.py egg_info for package Django
Downloading/unpacking Fabric==1.5.3 (from -r requirements.txt (line 2))
  Running setup.py egg_info for package Fabric
    warning: no previously-included files matching '*' found under directory 'docs/_build'
    warning: no previously-included files matching '*.pyc' found under directory 'tests'
    warning: no previously-included files matching '*.pyo' found under directory 'tests'
  Requested Fabric==1.5.3 (from -r requirements.txt (line 2)), but installing version 1.6.0
Downloading/unpacking South==0.7.6 (from -r requirements.txt (line 3))
  Downloading South-0.7.6.tar.gz (91kB): 91kB downloaded
  Running setup.py egg_info for package South
Downloading/unpacking argparse==1.2.1 (from -r requirements.txt (line 4))
  Downloading argparse-1.2.1.tar.gz (69kB): 69kB downloaded
  Running setup.py egg_info for package argparse
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.pyo' found anywhere in distribution
    warning: no previously-included files matching '*.orig' found anywhere in distribution
    warning: no previously-included files matching '*.rej' found anywhere in distribution
    no previously-included directories found matching 'doc/_build'
    no previously-included directories found matching 'env24'
    no previously-included directories found matching 'env25'
    no previously-included directories found matching 'env26'
    no previously-included directories found matching 'env27'
Downloading/unpacking django-annoying==0.7.6 (from -r requirements.txt (line 5))
  Downloading django-annoying-0.7.6.tar.gz
  Running setup.py egg_info for package django-annoying
Downloading/unpacking django-debug-toolbar==0.9.4 (from -r requirements.txt (line 6))
  Downloading django-debug-toolbar-0.9.4.tar.gz (150kB): 150kB downloaded
  Running setup.py egg_info for package django-debug-toolbar
    no previously-included directories found matching 'example'
Downloading/unpacking wsgiref==0.1.2 (from -r requirements.txt (line 7))
  Downloading wsgiref-0.1.2.zip
  Running setup.py egg_info for package wsgiref
Downloading/unpacking pexpect==2.4 (from -r requirements.txt (line 8))
  Downloading pexpect-2.4.tar.gz (113kB): 113kB downloaded
  Running setup.py egg_info for package pexpect
Downloading/unpacking gunicorn==0.17.2 (from -r requirements.txt (line 9))
  Downloading gunicorn-0.17.2.tar.gz (360kB): 360kB downloaded
  Running setup.py egg_info for package gunicorn
Requirement already satisfied (use --upgrade to upgrade): paramiko>=1.10.0 in /usr/lib/python2.6/site-packages (from Fabric==1.5.3->-r requirements.txt (line 2))
Requirement already satisfied (use --upgrade to upgrade): pycrypto>=2.1,!=2.4 in /usr/lib64/python2.6/site-packages (from paramiko>=1.10.0->Fabric==1.5.3->-r requirements.txt (line 2))
Installing collected packages: Django, Fabric, South, argparse, django-annoying, django-debug-toolbar, wsgiref, pexpect, gunicorn
  Running setup.py install for Django
    changing mode of build/scripts-2.6/django-admin.py from 644 to 755
    changing mode of /usr/bin/django-admin.py to 755
  Found existing installation: Fabric 1.6.0
    Uninstalling Fabric:
      Successfully uninstalled Fabric
  Running setup.py install for Fabric
    warning: no previously-included files matching '*' found under directory 'docs/_build'
    warning: no previously-included files matching '*.pyc' found under directory 'tests'
    warning: no previously-included files matching '*.pyo' found under directory 'tests'
    Installing fab script to /usr/bin
  Running setup.py install for South
  Running setup.py install for argparse
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.pyo' found anywhere in distribution
    warning: no previously-included files matching '*.orig' found anywhere in distribution
    warning: no previously-included files matching '*.rej' found anywhere in distribution
    no previously-included directories found matching 'doc/_build'
    no previously-included directories found matching 'env24'
    no previously-included directories found matching 'env25'
    no previously-included directories found matching 'env26'
    no previously-included directories found matching 'env27'
  Running setup.py install for django-annoying
  Running setup.py install for django-debug-toolbar
    no previously-included directories found matching 'example'
  Running setup.py install for wsgiref
  Running setup.py install for pexpect
  Running setup.py install for gunicorn
    Installing gunicorn_paster script to /usr/bin
    Installing gunicorn script to /usr/bin
    Installing gunicorn_django script to /usr/bin
Successfully installed Django Fabric South argparse django-annoying django-debug-toolbar wsgiref pexpect gunicorn
Cleaning up...
[localhost] local: python manage.py syncdb
Syncing...
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table south_migrationhistory

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'root'): admin # 環境に合わせて設定ください。
E-mail address: admin@localhost # 環境に合わせて設定ください。
Password: 
Password (again): 
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

Synced:
 > django.contrib.auth
 > django.contrib.contenttypes
 > django.contrib.sessions
 > django.contrib.sites
 > django.contrib.messages
 > django.contrib.staticfiles
 > django.contrib.admin
 > south

Not synced (use migrations):
 - aurora.cruiser
(use ./manage.py migrate to migrate these)
[localhost] local: python manage.py migrate
Running migrations for cruiser:
 - Migrating forwards to 0005_auto__del_field_stage_host__add_field_stage_hosts.
 > cruiser:0001_initial
 > cruiser:0002_auto__add_field_deploy_branch
 > cruiser:0003_auto__chg_field_deploy_status__chg_field_deploy_finished_at__chg_field
 > cruiser:0004_auto__add_field_deploy_comment
 > cruiser:0005_auto__del_field_stage_host__add_field_stage_hosts
 - Loading initial data for cruiser.
Installed 0 object(s) from 0 fixture(s)
[localhost] local: touch aurora/local_settings.py
[localhost] local: echo "DEBUG = True" > aurora/local_settings.py

Done.

これで、

python manage.py run_gunicorn

ってやると起動しますが、ローカルでしか動かない(0.0.0.0とかどうやって設定したらいいかわからなかったので)
とりあえず、Apacheのproxyで受けて後ろに流すだけという形で今回対応。

yum install httpd

んで、confの設定。includeしてvituralconfで対応します。セキュリティ設定とかその他、各自で。。。
(とりあえず、動かすこと目標。iptablesselinuxも止めちゃった。(*ノω・*)テヘ)

vim /etc/httpd/conf/httpd.conf

# 一番最後の行に追加
include /etc/httpd/conf/virtualhost_aurora.conf
vim /etc/httpd/conf/virtualhost_aurora.conf

<VirtualHost *:80>
        ServerName example.com
        ServerAlias example.com

        <Proxy *>
          Order allow,deny
          Allow from all
        </Proxy>

        #Directive to properly generate url (clone url) for pylons
        ProxyPreserveHost On

        ProxyPass / http://127.0.0.1:8000/
        ProxyPassReverse / http://127.0.0.1:8000/

        #to enable https use line below
        #SetEnvIf X-Url-Scheme https HTTPS=1

</VirtualHost>

これで、httpd起動して、python manage.py run_gunicorn とかするとWEBサイトは表示されますが、
デーモン化したいよねってことで、init scriptを作ります。
これ参考にちょっと変えただけ。
なんで2ポート立てないといけないかとわかんなかったんで、Pythonな方教えてください。m(_ _)m

PROJECTLOC等、各環境PATHはご自身の環境に合わせてください。

vim /etc/rc.d/init.d/gunicorn

#!/bin/sh
#
# gunicorn        Startup script for the gunicorn Server
#
# chkconfig: - 85 15
# description: The python Django gunicorn Server is an efficient and extensible  \
#              server implementing.

# processname: python
# config: /
# config: /
# pidfile: /$PROJECTLOC/$SERVER_PORT.pid
 
# http://nathanvangheem.com/news/gunicorn-startup-script-for-django
# Place the script in the file - /etc/init.d/gunicorn or whatever you'd like to call it
# make it executable - chmod +x /etc/init.d/gunicorn
# And finally, wire it up - update-rc.d gunicorn defaults
 
ADDRESS='127.0.0.1'
PYTHON="/usr/bin/python"
GUNICORN="/usr/bin/gunicorn_django"
PROJECTLOC="/home/aurora"
MANAGELOC="$PROJECTLOC/manage.py"
DEFAULT_ARGS="--workers=3 --daemon --bind=$ADDRESS:"
BASE_CMD="$GUNICORN $DEFAULT_ARGS"
 
SERVER1_PORT='8200'
SERVER1_PID="$PROJECTLOC/$SERVER1_PORT.pid"
SERVER2_PORT='8000'
SERVER2_PID="$PROJECTLOC/$SERVER2_PORT.pid"
 
start_server () {
  if [ -f $1 ]; then
    #pid exists, check if running
    if [ "$(ps -p `cat $1` | wc -l)" -gt 1 ]; then
       echo "Server already running on ${ADDRESS}:${2}"
       return
    fi
  fi
  cd $PROJECTLOC
  echo "starting ${ADDRESS}:${2}"
  $BASE_CMD$2 --pid=$1
}
 
stop_server (){
  if [ -f $1 ] && [ "$(ps -p `cat $1` | wc -l)" -gt 1 ]; then
    echo "stopping server ${ADDRESS}:${2}"
    kill -9 `cat $1`
    rm $1
  else 
    if [ -f $1 ]; then
      echo "server ${ADDRESS}:${2} not running"
    else
      echo "No pid file found for server ${ADDRESS}:${2}"
    fi
  fi
}
 
case "$1" in
'start')
  start_server $SERVER1_PID $SERVER1_PORT 
  start_server $SERVER2_PID $SERVER2_PORT
  ;;
'stop')
  stop_server $SERVER1_PID $SERVER1_PORT
  stop_server $SERVER2_PID $SERVER2_PORT
  ;;
'restart')
  stop_server $SERVER1_PID $SERVER1_PORT
  sleep 2
  start_server $SERVER1_PID $SERVER1_PORT
  sleep 2
  stop_server $SERVER2_PID $SERVER2_PORT
  sleep 2
  start_server $SERVER2_PID $SERVER2_PORT
  ;;
*)
  echo "Usage: $0 { start | stop | restart }"
  ;;
esac
 
exit 0

あとは、chkconfig追加したら、OKっと。。。

chmod 755 /etc/init.d/gunicorn
chkconfig gunicorn on
chkconfig httpd on

/etc/init.d/gunicorn restart
/etc/init.d/httpd restart

とかで、起動、再起動とかできるようになりました。ちなみに、auroraの画面はこんな感じです。
auroraが動くのは簡単に確認してますが、Fabric連携とかまだです。。。
ホントに導入しただけの状態ですんであしからず。。。m(_ _)m

■ログイン画面

■ログイン後

■プロジェクト追加

■ステージ追加

■タスク追加

■管理画面

windows環境にネイティブ?なnode.jsとredisを構築する

お仕事の都合で、やっぱりWindowsは必要なんですよーねぇー。
いや、いいOSですよ。Windows 基本ですよねぇー!!(* >ω<)

ということで、VirtualBoxとかに環境を作るのは別として、直接node.jsな環境を構築します。
かなり、あっさりいったので、自分では驚きというか、案外イケルじゃん!!ってので、
WindowsApacheたてて、うにゃむにゃ。。。するより、こっちのほうが開発しやすいんじゃないかと思ったりします。

Windows8Pro(64bit)環境に、node.js 0.10.1を導入しました。(異なるVerだとちょっと違ったりするのかな?)

■node.jsの導入

結論から言うと、インストーラーダウンロードしてきて、インストールして終わり。(∩´∀`)∩ワーイ なんて簡単。。。

公式サイト http://nodejs.org/download/ 自分の環境に合わせたからインストーラーをダウンロード。
日本サイトだとこっち http://nodejs.jp/nodejs.org_ja/docs/v0.10/download/

環境変数とか設定しないとイケないかと思いましたが、する必要はありませんでした。

コマンドプロンプトで操作できるみたいですが 「Node.js command prompt」なるものがインストールされていて、そっちを基本的には使っています。

npmとかもちゃんと動いてnode_modulesインストールできました。

■redisの導入

Microsoftさんが、redisをWindowsで動くようにしてくれたりします。
githubのバイナリ持ってきて、解凍して基本終わり。

以下を参照しました。書く必要がないくらい、まとめられています。
http://it-shimotori.blogspot.jp/2012/08/install-redis-on-windows.html

リポジトリはこちらです。 https://github.com/MSOpenTech/redis

https://github.com/MSOpenTech/redis/tree/2.4/msvs/bin/release 
から環境に合わせたバイナリ(redisbin)と、rediswatcherbin.zip をダウンロードします。

watcher使用しなくても、コマンドプロンプトが立ち上がったまま(゜Д゜)ウゼェェェって、
ならなければ、redis-server.exeクリックするだけで、ローカルからのアクセスは問題なくできます。

(゜Д゜)ウゼェェェ場合は、rediswathcerbin.zip解凍して、InstallWatcher.msiをクリックして、インストールします。

C:\Program Files (x86)\RedisWatcher

にインストールされます。

インストールすると、watcher.confで、PATH設定する必要があるんですが、変更するのが面倒なら、
以下のフォルダを作成します。

c:\redis\bin  ※redis-server.exeをここの放り込む
c:\redis\inst1 ※ワーキングディレクト

binフォルダにredisサーバ(redis-server.exe)を放り込んで、ワーキングディレクトリってのを作ってます。

あとは、「コントロールパネル」 ー 「管理ツール」 ー 「サービス」を開いて、
Redis watherのところで、右クリックで開始します。

最後に、動作確認として、redisbinを解凍した中にある、redis-cli.exeを立ちあげて、
問題なければ、サービスモードで起動しています。

あとは、DBの問題あるけど、DBは共用で使いたいことの方が多いと思うので、個別の開発環境用意というよりかは、
各自自分でやってねって言えるレベルなので、運用しやすいんじゃないでしょうか。

Windows8を快適に使うには、ショートカットキーを覚えることが大事。

LinuxデスクトップにKVMWindows使ってたけど、Windows Update後の再起動で、起動しなくなって、
(どうやら、ドライバか何か原因で、破損した)かなり困ったので、結局ノートPCはWindows環境にしました。
で、せっかくなので、検証環境も含めて、Windows8にしたけど、今までの慣れがある分、結構しんどい。。。
スタートメニューを表示させたら負けな気がしているので、そこはぐっと堪えて、新しいものを使いこなせるまでの
慣れの苦行を積んでおります。

でも、以下のショートカットキーを覚えると、昔ながらに快適に使えることが判明。
(それがそもそもどうなのかというのがあるが。。。)

Windows + D デスクトップの表示
Windows + E エクスプローラーの表示
Windows + I 設定の呼び出し
Windows + C チャームの表示
Windows + Q アプリの検索+プログラムの一覧表示
Windows + F ファイルの検索
Windows + X コントロールパネル内の機能一覧表示
Windows + L windowsのロック

最近Macをあんまり触らず、Linux、Winがメインな生活になっております。

初めてpull requestしてmergeされたので記念カキコ

お世話になってる、フレームワークで、簡単なもんだけど、pullリクエストしました。

http://d.hatena.ne.jp/hnw/20110528 参考にしましたが、gitムズい。。。orz

送ったのはこれ。pullreq PostgreSQL対応ですね。
まぁ、簡単。あと日本語訳もマージしてもらえました。

マージも無事されてちょっと嬉しいですね。こういうの♪♪ヽ(゚∀゚)メ(゚∀゚)メ(゚∀゚)ノ