DRY

Web関連の技術の事、食事/お酒の事、旅行の事など

windows+cygwinでdotcloudする

Androidアプリを作っているのですが、サーバサイドもそろそろ必要だな〜と言う事でdotcloudを使ってみる事にしました。

Macにも環境を作ろうと思いますが、まずはWindows7 + cygwinで作ってみます。

dotcloudのinviteは1日掛からずぐらいで来ました。

cygwinが入っているのは前提で、rsyncとopensshも入れておきます。
ちなみにc:\cygwinです。pathも通してあります。

pythonDownload Python | Python.orgから、C:\Python27にインストール
私の場合は「Python 2.7.1 Windows X86-64 Installer」ですね。

こちらの、Package IndexのページからPyPI - the Python Package Index : Python Package Index、dotcloudで検索して「dotcloud.cli 0.3.1」をダウンロード
C:\Python27\Lib\site-packagesにtar.gzを展開

C:\Python27\Tools\Scriptsに以下のコードをdotcloud.pyというファイル名で作成する
参考ページ

#!python.exe

from dotcloudcli import cli

if __name__ == '__main__':
cli.main()

で、準備完了との事なのでcygwin起動して

user@machine /cygdrive/c/Python27
$ cd /cygdrive/c/Python27/Tools/Scripts/

user@machine /cygdrive/c/Python27/Tools/Scripts
$ ./dotcloud.py
Traceback (most recent call last):
File "./dotcloud.py", line 3, in
from dotcloudcli import cli
ImportError: No module named dotcloudcli

となる。。。正直python良くわからないので、どうしたものかと。

でも、よくよく考えてみて、そもそもcygwinに「easy_install」入れればいいんじゃないか?って事で試してみる事に。

コチラのページを参考にさせて貰い、ez_setup.pyを取得。
そいつを/cygdrive/c/Python27/Tools/Scriptsにコピーして置く。

C:\Python27\Tools\Scriptsにもpathを通して、cygwin上でコマンドを実行してみる。

user@machine /cygdrive/c/Python27/Tools/Scripts
$ python.exe ez_setup.py
Downloading http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
Processing setuptools-0.6c11-py2.6.egg
Copying setuptools-0.6c11-py2.6.egg to /usr/lib/python2.6/site-packages
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install script to /usr/bin
Installing easy_install-2.6 script to /usr/bin

Installed /usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11

easy_installがインストールされたか、直接コマンドで試してみる。

$ easy_install dotcloud
Searching for dotcloud
Reading http://pypi.python.org/simple/dotcloud/
Reading http://www.dotcloud.com
Reading http://www.dotcloud.com/
Best match: dotcloud 0.3.1
Downloading http://pypi.python.org/packages/source/d/dotcloud/dotcloud-0.3.1.tar.gz#md5=8258828acb0bc0b6894b3c39dd9e6c42
Processing dotcloud-0.3.1.tar.gz
Running dotcloud-0.3.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-seUrmG/dotcloud-0.3.1/egg-dist-tmp-EoXQ1W
Adding dotcloud 0.3.1 to easy-install.pth file

Installed /usr/lib/python2.6/site-packages/dotcloud-0.3.1-py2.6.egg
Processing dependencies for dotcloud
Searching for dotcloud.cli>=0.3.1
Reading http://pypi.python.org/simple/dotcloud.cli/
Best match: dotcloud.cli 0.3.1
Downloading http://pypi.python.org/packages/source/d/dotcloud.cli/dotcloud.cli-0.3.1.tar.gz#md5=99f32013cee617447f5adc3e59683163
Processing dotcloud.cli-0.3.1.tar.gz
Running dotcloud.cli-0.3.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-fK9odK/dotcloud.cli-0.3.1/egg-dist-tmp-1jhFwl
Adding dotcloud.cli 0.3.1 to easy-install.pth file
Installing dotcloud script to /usr/bin
Installing __dotcloud_git_ssh script to /usr/bin

Installed /usr/lib/python2.6/site-packages/dotcloud.cli-0.3.1-py2.6.egg
Finished processing dependencies for dotcloud

問題なくインストール出来たっぽい!
なので、引き続きdotcloudを使ってみる。

user@machine /cygdrive/c/Python27/Tools/Scripts
$ dotcloud create remen
Warning: /home/xxx/.dotcloud/dotcloud.conf does not exist.
Enter your api key (You can find it at http://www.dotcloud.com/account/settings)
: 「dotcloudのページのsettingに表示されているAPIKey」
Created "remen"

※「remen」は特に意味ないです。ramenじゃなくて。。。みたいな

アプリは出来たようだが、Warning: /home/xxx/.dotcloud/dotcloud.conf does not exist.的な警告が。
とりあえず、今度調べる。

後は、サーバーサイドが欲しいのでとりあえずnode.jsの環境を選択。

user@machine /cygdrive/c/Python27/Tools/Scripts
$ dotcloud deploy -t nodejs remen.node
Created "remen.node".

ちなみにdotcloudのトップページにアイコンがたくさんあるように、いろいろサービスを選択できるようだ。

$ dotcloud deploy -h
You can chose among the following services:
java host any Java servlet (also Clojure, Play!, and much more)
mongodb scalable, high-performance, document-oriented database
mysql the world's most popular open source database
nodejs run JavaScript processes (including web apps)
perl host any Perl/PSGI web app: Plack, Mojolicious, Dancer...
php host any PHP web app: Drupal, WordPress...
php-worker run background PHP processes
postgresql the world's most advanced open source database
python host any Python/WSGI web app: Django, Pylons, Web2py...
python-worker run background Python processes
rabbitmq AMQP message queue server
redis advanced key-value store
ruby host any Ruby/Rack web app: Rails, Sinatra...
ruby-worker run background Ruby processes
smtp authenticated SMTP relay to send e-mails reliably
solr the search server based on the Lucene Java search library
static host static HTTP content


で、dotcloudに上げる方の自分の環境を、/home/dotcloudにする。

user@machine ~
$ cd /home

user@machine /home
$ mkdir dotcloud

user@machine /home
$ cd dotcloud/

user@machine /home/dotcloud
$ pwd
/home/dotcloud

その下に、server.js

var http = require ('http');
http.createServer (function (req,res) {
res.writeHead (200, {'Content-Type': 'text/plain'});
res.end ('Hello dotcloud!!');
}).listen (8080);

supervisord.conf

[program:node]
command = node server.js
directory = /home/dotcloud

をそれぞれ配置し、これらのファイルをdotcloudにpush

user@machine /cygdrive/d/Develop/dotcloud
$ dotcloud push remen.node .
# upload . ssh://dotcloud@uploader.dotcloud.com:21122/myapp.node
# rsync
1 [main] python 3032 C:\cygwin\bin\python.exe: *** fatal error - unable to
remap \\?\C:\cygwin\lib\python2.6\lib-dynload\time.dll to same address as paren
t: 0x360000 != 0x410000
Stack trace:
Frame Function Args
00289758 6102796B (00289758, 00000000, 00000000, 00000000)
00289A48 6102796B (6117EC60, 00008000, 00000000, 61180977)
0028AA78 61004F1B (611A7FAC, 61243A84, 00360000, 00410000)
End of stack trace
0 [main] python 7972 fork: child 3032 - died waiting for dll loading, errn
o 11
Error: "rsync" failed to be executed. Please make sure it is properly installed.

また意味わかんないエラーが。。。

そいで、再び調べてみると、コチラに対処方法っぽいのが書いてあったので、まんま試して見る事に。

1) 開いているcygwin全部閉じて
2) Windowsコマンドプロンプト開く
3) c:\cygwin\binディレクトリへ移動
4) ashと打って
5) '/usr/bin/rebaseall'と打つ
6) そのまま終わるまで待つ
7) 再起動


再びトライ。

nagashima@nagashima-dt096 /home/dotcloud
$ dotcloud push remen.node .
# upload . ssh://dotcloud@uploader.dotcloud.com:21122/remen.node
# rsync
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: Permanently added '[uploader.dotcloud.com]:21122,[184.73.14.49]:21122'
(RSA) to the list of known hosts.
building file list ... done
./
server.js

sent 266 bytes received 40 bytes 47.08 bytes/sec
total size is 252 speedup is 0.82
Scheduling build
Fetching logs...
Warning: Permanently added '[node.remen.dotcloud.com]:7065,[174.129.17.131]:7065
' (RSA) to the list of known hosts.

    • Beginning the build process [build:b6600d1dfa22]

./
./supervisord.conf
./server.js
Fetched code revision rsync-1307509843.25
node: stopped
node: started
Connection to node.remen.dotcloud.com closed.

で、node.remen.dotcloud.comをブラウザでそのまま(port80)で見てみると。。。

成功だ!
あとはPSGIとかもやってみたいので、ちゃんとサービス作り直すかな。