読者です 読者をやめる 読者になる 読者になる

なんとな~くしあわせ?の日記

ClojureとかAWSの設定とかをメモする技術ブログ

Heroku + Plack + plenvを試す



ある目的のためにPlackをHerokuに上げたいと思っていた。で、試したので手順を書いておく。

plack-testing

今回試したリポジトリ
github.com

手順

初期設定

plenv

Rubyで言うところのrbenv、結構古いPerlじゃないと依存関係がぶっ壊れる

$ git clone git://github.com/tokuhirom/plenv.git ~/.plenv
$ git clone git://github.com/tokuhirom/Perl-Build.git ~/.plenv/plugins/perl-build/
$ echo 'export PATH="$HOME/.plenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(plenv init -)"' >> ~/.bash_profile
$ exec $SHELL -l
$ plenv install 5.16.3

cpanm

  • cpan minusという意味らしい、cpan plusというcpanの拡張版の機能軽量化版だと思われる
  • Rubyで言うところのGemfileである
  • cpanfileに依存関係を記述する、そんでcpanmを実行
$ mkdir bin
$ cd bin
$ curl -LOk http://xrl.us/cpanm
$ chmod +x cpanm
インストールとアプリケーションサーバの起動
$ bin/cpanm -L . --installdeps .
$ ./start.sh
Heroku / Heroku buildpack: Perl
  • ここ必見、HerokuにPerlのアプリケーションを上げる時、これが使える

qiita.com

  • heroku createがHeroku上にアプリを登録する
  • git push heroku masterは今のコードをHerokuにデプロイする、まあなんてクリアなコードでデプロイ出来るんでしょう
$ heroku create --buildpack http://github.com/pnu/heroku-buildpack-perl.git
$ git push heroku master
Counting objects: 22, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (22/22), 3.04 KiB | 0 bytes/s, done.
Total 22 (delta 7), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Perl/PSGI app detected
remote: -----> Vendoring https://heroku-buildpack-perl.s3.amazonaws.com/cedar-14/perl-5.16.3.tgz
remote: -----> Vendoring https://heroku-buildpack-perl.s3.amazonaws.com/cedar-14/perl-5.16.3-extras.tgz
remote: -----> Current perl version is 5.16.3
remote: -----> Random RELEASE_UUID=794f391bff3b74b4946ff4ecebd3aad70b87ea46915f22c782a1b6762b0d08ee
remote: -----> Bootstrapping cpanm and local::lib
remote:        Successfully installed App-cpanminus-1.7042 (upgraded from 1.7014)
remote:        Successfully installed local-lib-2.000019 (upgraded from 2.000014)
remote:        2 distributions installed
remote: -----> Installing dependencies (cpanm)
remote:        Successfully installed JavaScript-Value-Escape-0.07
remote:        Successfully installed Plack-Middleware-ConsoleLogger-0.05
remote:        Successfully installed CGI-4.33 (upgraded from 3.59)
remote:        Successfully installed CGI-Emulate-PSGI-0.22
remote:        Successfully installed CGI-Compile-0.21
remote:        Successfully installed Plack-Middleware-Auth-Digest-0.05
remote:        Successfully installed Plack-Middleware-Deflater-0.12
remote:        Successfully installed AnyEvent-HTTP-2.23
remote:        Successfully installed Plack-App-Proxy-0.29
remote:        Successfully installed CGI-PSGI-0.15
remote:        Successfully installed asa-1.03
remote:        Successfully installed IO-Handle-Util-0.01
remote:        Successfully installed Any-Moose-0.26
remote:        Successfully installed FCGI-Client-0.08
remote:        Successfully installed Text-MicroTemplate-0.24
remote:        Successfully installed Plack-Middleware-Debug-0.16
remote:        Successfully installed Test-HexString-0.03
remote:        Successfully installed Net-FastCGI-0.14
remote:        Successfully installed Canary-Stability-2012
remote:        Successfully installed Coro-6.511
remote:        Successfully installed Net-Server-Coro-1.3
remote:        Successfully installed Corona-0.1004
remote:        Successfully installed Plack-Middleware-Header-0.04
remote:        Successfully installed PSGI-1.102
remote:        Successfully installed Server-Starter-0.32
remote:        Successfully installed IO-Socket-IP-0.38
remote:        Successfully installed Test-TCP-2.17 (upgraded from 2.06)
remote:        Successfully installed Class-Accessor-Lite-0.08
(省略)
remote:        Successfully installed Proc-Wait3-0.05
remote:        Successfully installed IPC-Signal-1.00
remote:        Successfully installed Signal-Mask-0.008
remote:        Successfully installed Parallel-Prefork-0.18
remote:        Successfully installed Starlet-0.30
remote:        Successfully installed Cookie-Baker-0.07
remote:        Successfully installed Plack-Middleware-Session-0.30
remote:        Successfully installed Task-Plack-0.28
remote:        36 distributions installed
remote: -----> Installing Starman
remote:        Successfully installed Starman-0.4014 (upgraded from 0.4010)
remote:        1 distribution installed
remote: -----> Caching local to /app/tmp/cache/perl/cedar-14/
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> web
remote: 
remote: -----> Compressing...
remote:        Done: 31M
remote: -----> Launching...
remote:        Released v4
remote:        https://thawing-savannah-27493.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy.... done.
To https://git.heroku.com/thawing-savannah-27493.git