bin/riji
#!/usr/bin/perl
use strict;
use warnings;
use Riji::CLI;
Riji::CLI->run(@ARGV);
scriptにはあまり書かないでテスタブルにする
PSGI/Plackアプリケーションの起動方法いろいろと本番環境アレコレ
http://blog.nomadscafe.jp/2013/06/psgiplack.html
http://www.songmu.jp/riji/entry/2013-10-30-orepan2-inject-psgi.html
use OrePAN2::Injector;
use OrePAN2::Indexer;
use Plack::Request;
use File::Copy qw/move/;
use File::Temp qw/tempdir/;
use File::Spec;
sub {
my $env = shift;
my $req = Plack::Request->new($env);
local $@;
if ($req->method eq 'POST') {
eval {
my $directory = './oreorepanpan';
my ($module, $author);
my $tempdir = tempdir( CLEANUP => 1 );
if (my $upload = $req->upload('pause99_add_uri_httpupload')) {
$module = File::Spec->catfile($tempdir, $upload->filename);
move $upload->tempname, $module;
$author = $req->param('HIDDENNAME');
}
else {
$module = $req->param('module'); # can be a git repo.
$author = $req->param('author') || 'DUMMY';
}
my $injector = OrePAN2::Injector->new(
directory => $directory,
author => $author,
);
$injector->inject($module);
OrePAN2::Indexer->new(directory => $directory)->make_index(
no_compress => 1,
);
};
}
if (my $err = $@) {
[500, [], [$err.'']]
}
else {
[200, [], ['OK']]
}
};
after
#!/usr/bin/env perl
use strict;
use warnings;
use OrePAN2::Server::CLI;
OrePAN2::Server::CLI->new(@ARGV)->run;
https://metacpan.org/release/Puncheur