最近Webアプリを自分でも積極的に作らないとという衝動に駆られ、まずはフレームワークをインストールしてみました。いろいろはまったのでメモ。
Arkのダウンロード
まずはArkのダウンロード。typestarさんのgithubにあるのでそこからclone。
$ git clone http://github.com/typester/ark-perl.git
依存モジュールのインストール
cpanモジュールをインストールします。
$ cd ark-perl $ sudo perl Makefile.pl $ sudo -H make installdeps
Arkのインストール
テストを実行してから、インストール。
$ sudo make test $ sudo make install
これでArkがインストールされます。
アプリケーションを作成
まず、はまったところ一つ目。Module::Setup::Pluginが悪さをして、アプリケーション作成ができない。とりあえずModule::Setup::Pluginの
sub add_trigger { my($self, @args) = @_; $self->{context}->add_trigger(@args); }
の部分を
sub add_trigger { my($self, @args) = @_; $self->{context}->add_trigger(@args) if $self->{context}; }
に変更。これで、次のようにするとアプリケーションが作れる。
$ ark.pl newapp Jobeet
アプリケーションの立ち上げ
さて、次はアプリケーションをサーバで立ち上げるのだが、ここでもはまった。まず
ark.pl server
で立ち上げようとすると、plackupを使ってくださいねと言われる。そこで次のやり方で立ち上げる。
plackup app.psgi
するとエラーが発生する。
Error while loading app.psgi: Can't locate Jobeet.pm in @INC (@INC contains: /opt/local/lib/perl5/site_perl/5.8.9/darwin-2level /opt/local/lib/perl5/site_perl/5.8.9 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl/5.8.9/darwin-2level /opt/local/lib/perl5/vendor_perl/5.8.9 /opt/local/lib/perl5/vendor_perl /opt/local/lib/perl5/5.8.9/darwin-2level /opt/local/lib/perl5/5.8.9 .) at app.psgi line 4. BEGIN failed--compilation aborted at app.psgi line 4.
ふむ、libパスが通ってないのか。なんで通ってないのかわからないけどとりあえずFindBinを使って、、、と思ったらFindBinがなぜか使えなかったのでapp.psgiの先頭くらいに次の事を追記して修正。
use lib './lib';
かなり強引にやったんだが、この状態でもう一回plackup app.psgiを打つとちゃんと起動された。
[debug] Loaded Path actions: .-------------------------------------+--------------------------------------.
Path | Private |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/ | /index |
/ | /default |
これでhttp://0:5000/にアクセス。
ちゃんとできてそう。よかった。