dotcloud + node.jsでHello World
dotcloud + node.jsやってみました。
まずdotcloudをインストールする。特に問題ない。
$ sudo easy_install dotcloud
アプリケーションをつくる。APIキーを設定してない場合は設定しろと出るので指示通りsettingsページに書いてあるAPIキーを入力する。
$ dotcloud create hokaccha
Warning: /Users/hokamura/.dotcloud/dotcloud.conf does not exist.
Enter your api key (You can find it at http://www.dotcloud.com/account/settings):
プロジェクトを作る。
$ dotcloud deploy -t nodejs hokaccha.helloworld
Created "hokaccha.helloworld".
最低限必要なのはsupervisord.confという設定ファイル。ここで起動用のスクリプトを指定する。supervisord.confの中身はこんな感じ。
[program:node]
command = node server.js
directory = /home/dotcloud/current
同じディレクトリに指定したserver.jsを置いてHello Worldの出力するサーバーを書く。
var http = require('http');
http.createServer(function (req, res){
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World!!');
}).listen(8080);
これでこの二つのファイルを置いたディレクトリを指定してアップする。
$ dotcloud push hokaccha.helloworld .
これだけだった。10分くらいでできて超簡単。
http://helloworld.hokaccha.dotcloud.com/
- Prev Entry:続・iOSのSafariで特定のfont-sizeのときの謎の隙間
- Next Entry:Firefox5でCSSの@keyframesにクオートがあると動かない件について