Skip to content

Commit

Permalink
fix demo app to run under new Catalyst ScriptRunner and new Schema Lo…
Browse files Browse the repository at this point in the history
…ader
  • Loading branch information
ollyg committed Oct 9, 2011
1 parent b096a41 commit 76b26d1
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 85 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Catalyst-Plugin-AutoCRUD-*
lib/Catalyst/Plugin/AutoCRUD/static/ext2
examples/sandpit/dbictest.sql
examples/sql/__autocrud_testapp.sqlite
2 changes: 1 addition & 1 deletion dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Catalyst::Runtime = 5.70
Catalyst::Action::RenderView = 0

[@Author::OLIVER]
skip_files = ^examples/sandpit|^lib/Catalyst/Plugin/AutoCRUD/static/ext2
skip_files = ^examples/sandpit|^lib/Catalyst/Plugin/AutoCRUD/static/ext2|^examples/sql/__autocrud_testapp.sqlite
major_version = 2
6 changes: 3 additions & 3 deletions examples/demo/demo.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</connect_info>
</Model::AutoCRUD::DBIC>

#<Plugin::AutoCRUD>
<Plugin::AutoCRUD>
# extjs2 /static/extjs-2
# basepath cpac
basepath ""
#
# <sites>
# <default>
Expand All @@ -31,4 +31,4 @@
# </dbic>
# </default>
# </sites>
#</Plugin::AutoCRUD>
</Plugin::AutoCRUD>
113 changes: 33 additions & 80 deletions examples/demo/server.pl
Original file line number Diff line number Diff line change
@@ -1,69 +1,18 @@
#!/usr/bin/perl -w

BEGIN {
$ENV{CATALYST_ENGINE} ||= 'HTTP';
$ENV{CATALYST_SCRIPT_GEN} = 31;
require Catalyst::Engine::HTTP;
}

use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use FindBin;
#!/usr/bin/env perl

BEGIN {
$ENV{CATALYST_SCRIPT_GEN} = 40;
}

# check we can load files needed for the demo app
use FindBin;
use lib "$FindBin::Bin/lib";
eval { require Catalyst::Plugin::AutoCRUD }
or eval { use lib "$FindBin::Bin/../../lib" };
use DemoApp;

my $debug = 0;
my $fork = 1;
my $help = 0;
my $host = undef;
my $port = $ENV{CATALYST_PORT} || 3000;
my $keepalive = 0;
my $restart = $ENV{CATALYST_RELOAD} || 0;
my $restart_delay = 1;
my $restart_regex = '(?:/|^)(?!\.#).+(?:\.yml$|\.yaml$|\.conf|\.pm)$';
my $restart_directory = undef;
my $follow_symlinks = 0;

my @argv = @ARGV;

GetOptions(
'debug|d' => \$debug,
'fork' => \$fork,
'help|?' => \$help,
'host=s' => \$host,
'port=s' => \$port,
'keepalive|k' => \$keepalive,
'restart|r' => \$restart,
'restartdelay|rd=s' => \$restart_delay,
'restartregex|rr=s' => \$restart_regex,
'restartdirectory=s@' => \$restart_directory,
'followsymlinks' => \$follow_symlinks,
);

pod2usage(1) if $help;

if ( $restart && $ENV{CATALYST_ENGINE} eq 'HTTP' ) {
$ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
}
if ( $debug ) {
$ENV{CATALYST_DEBUG} = 1;
}

DemoApp->run( $port, $host, {
argv => \@argv,
'fork' => $fork,
keepalive => $keepalive,
restart => $restart,
restart_delay => $restart_delay,
restart_regex => qr/$restart_regex/,
restart_directory => $restart_directory,
follow_symlinks => $follow_symlinks,
} );
use Catalyst::ScriptRunner;
Catalyst::ScriptRunner->run('DemoApp', 'Server');

1;

Expand All @@ -75,25 +24,28 @@ =head1 SYNOPSIS
server.pl [options]
Options:
-d -debug force debug mode
-f -fork handle each request in a new process
(defaults to false)
-? -help display this help and exits
-host host (defaults to all)
-p -port port (defaults to 3000)
-k -keepalive enable keep-alive connections
-r -restart restart when files get modified
(defaults to false)
-rd -restartdelay delay between file checks
-rr -restartregex regex match files that trigger
a restart when modified
(defaults to '\.yml$|\.yaml$|\.conf|\.pm$')
-restartdirectory the directory to search for
modified files, can be set mulitple times
(defaults to '[SCRIPT_DIR]/..')
-follow_symlinks follow symlinks in search directories
(defaults to false. this is a no-op on Win32)
-d --debug force debug mode
-f --fork handle each request in a new process
(defaults to false)
-? --help display this help and exits
-h --host host (defaults to all)
-p --port port (defaults to 3000)
-k --keepalive enable keep-alive connections
-r --restart restart when files get modified
(defaults to false)
-rd --restart_delay delay between file checks
(ignored if you have Linux::Inotify2 installed)
-rr --restart_regex regex match files that trigger
a restart when modified
(defaults to '\.yml$|\.yaml$|\.conf|\.pm$')
--restart_directory the directory to search for
modified files, can be set multiple times
(defaults to '[SCRIPT_DIR]/..')
--follow_symlinks follow symlinks in search directories
(defaults to false. this is a no-op on Win32)
--background run the process in the background
--pidfile specify filename for pid file
See also:
perldoc Catalyst::Manual
perldoc Catalyst::Manual::Intro
Expand All @@ -108,7 +60,8 @@ =head1 AUTHORS
=head1 COPYRIGHT
This library is free software, you can redistribute it and/or modify
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut

2 changes: 1 addition & 1 deletion lib/Catalyst/Plugin/AutoCRUD.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ sub setup_components {
if eval "$DBIx::Class::Schema::Loader::VERSION" <= 0.04005;

DBIx::Class::Schema::Loader::make_schema_at(
'AutoCRUD::Loader::Schema', {},
'AutoCRUD::Loader::Schema', {naming => 'current'},
$class->config->{$p}->{connect_info},
);

Expand Down

0 comments on commit 76b26d1

Please sign in to comment.