Permalink
Browse files

prepare to be able to run as a fastcgi application on the production …

…server
  • Loading branch information...
1 parent 54a989f commit 2be554a5289d9705d83911458e4aa979736a7d07 @szabgab committed May 8, 2011
View
2 CPAN-Digger-WWW.pl → bin/app.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
use Dancer;
-use lib path(dirname(__FILE__), 'lib');
+use lib path(dirname(__FILE__), '..', 'lib');
#load_app 'CPAN::Digger::WWW';
use CPAN::Digger::WWW;
dance;
View
4 config.yml
@@ -1,8 +1,8 @@
#layout: "main"
#environment: development
appname: "CPAN::Digger::WWW"
-#logger: "file"
-logger: 'console'
+logger: "file"
+#logger: 'console'
template: template_toolkit
#daemon: 0 # setting to 1 does not do anything on Windows?
charset: utf-8
View
2 environments/development.yml
@@ -5,4 +5,4 @@ show_errors: 1
# auto_reload is a development feature
# you should enable it by yourself if you want it
# Module::Refresh is needed
-auto_reload: 1
+auto_reload: 0
View
8 environments/test.yml
@@ -0,0 +1,8 @@
+log: "core"
+warnings: 1
+show_errors: 1
+
+# auto_reload is a development feature
+# you should enable it by yourself if you want it
+# Module::Refresh is needed
+auto_reload: 0
View
1 lib/CPAN/Digger/DB.pm
@@ -18,6 +18,7 @@ sub setup {
my $dbfile = $self->dbfile;
my $dbdir = dirname $dbfile;
+# die("Creating '$dbdir'");
mkpath $dbdir if not -d $dbdir;
system "sqlite3 $dbfile < schema/digger.sql" if not -e $dbfile;
$self->dbh( DBI->connect("dbi:SQLite:dbname=$dbfile","","", {RaiseError => 1, PrintError => 0, AutoCommit => 1}) );
View
25 public/dispatch.fcgi 100644 → 100755
@@ -1,8 +1,25 @@
-#!/usr/bin/perl
-use Plack::Handler::FCGI;
+#!/usr/bin/env perl
+
+BEGIN {
+$ENV{CPAN_DIGGER_DBFILE} = '/home/gabor/work/digger/digger.db';
+#warn "P: $ENV{PERL5LIB}";
+ use lib '/home/gabor/perl5/local/lib/perl5';
+ use lib '/home/gabor/perl5/local/lib/perl5/x86_64-linux-gnu-thread-multi';
+}
+
use Dancer ':syntax';
+use FindBin '$RealBin';
+use Plack::Handler::FCGI;
+
+# For some reason Apache SetEnv directives dont propagate
+# correctly to the dispatchers, so forcing PSGI and env here
+# is safer.
+set apphandler => 'PSGI';
+#set environment => 'production';
+set environment => 'test';
-my $psgi = path(dirname(__FILE__), '..', 'CPAN-Digger-WWW.pl');
+my $psgi = path($RealBin, '..', 'bin', 'app.pl');
my $app = do($psgi);
-my $server = Plack::Handler::FCGI->new(nproc => 5, detach => 1);
+my $server = Plack::Handler::FCGI->new(nproc => 5, detach => 1);
+
$server->run($app);
View
1 schema/digger.sql
@@ -7,6 +7,7 @@ CREATE TABLE distro (
file_timestamp DATE,
added_timestamp DATE
);
+CREATE INDEX distro_author_idx ON distro (author);
CREATE TABLE author (
pauseid VARCHAR(50) PRIMARY KEY,
View
5 t/01-collect.t
@@ -14,7 +14,7 @@ use Test::More;
use Test::Deep;
use Test::NoWarnings;
-plan tests => 14 + 10 + 1;
+plan tests => 14 + 11 + 1;
my $cleanup = !$ENV{KEEP};
@@ -259,7 +259,8 @@ $ENV{CPAN_DIGGER_DBFILE} = $dbfile;
{
my $r = dancer_response(GET => '/id/FAKE1');
is $r->{status}, 200, 'OK';
-# diag $r->{content};
+ #diag $r->{content};
+ like Encode::encode('utf8', $r->{content}), qr{$expected_authors{FAKE1}{name}}, 'name is in the content';
}
{

0 comments on commit 2be554a

Please sign in to comment.