support for running from git or build dir

This commit is contained in:
Oliver Gorwits
2013-03-04 20:31:32 +00:00
parent c4e6e4c8eb
commit 376b1cf9dd
2 changed files with 21 additions and 12 deletions

View File

@@ -1,11 +1,20 @@
#!/usr/bin/env perl #!/usr/bin/env perl
use FindBin; use FindBin;
use lib "$FindBin::Bin/../lib"; FindBin::again();
use App::Netdisco; use Path::Class 'dir';
BEGIN {
# stuff useful locations into @INC
unshift @INC,
dir($FindBin::RealBin)->parent->subdir('lib')->stringify,
dir($FindBin::RealBin, 'lib')->stringify;
}
# for netdisco app config # for netdisco app config
use App::Netdisco;
use Dancer qw/:moose :script/; use Dancer qw/:moose :script/;
info "App::Netdisco version $App::Netdisco::VERSION daemon loaded.";
# callbacks and local job queue management # callbacks and local job queue management
use App::Netdisco::Daemon::Queue ':all'; use App::Netdisco::Daemon::Queue ':all';
@@ -13,15 +22,13 @@ use App::Netdisco::Daemon::Queue ':all';
# needed to quench AF_INET6 symbol errors # needed to quench AF_INET6 symbol errors
use NetAddr::IP::Lite ':lower'; use NetAddr::IP::Lite ':lower';
# set temporary MCE files' location in home directory
use Path::Class 'dir';
my $tmp_dir = ($ENV{NETDISCO_TEMP} || dir($ENV{HOME}, 'tmp'));
mkdir $tmp_dir if ! -d $tmp_dir;
use MCE; use MCE;
use Role::Tiny::With; use Role::Tiny::With;
info "App::Netdisco version $App::Netdisco::VERSION daemon loaded."; # set temporary MCE files' location in home directory
my $home = ($ENV{NETDISCO_HOME} || $ENV{HOME});
my $tmp_dir = ($ENV{NETDISCO_TEMP} || dir($home, 'tmp'));
mkdir $tmp_dir if ! -d $tmp_dir;
my $mce = MCE->new( my $mce = MCE->new(
spawn_delay => 0.15, spawn_delay => 0.15,

View File

@@ -3,13 +3,15 @@
use strict; use strict;
use warnings FATAL => 'all'; use warnings FATAL => 'all';
use FindBin;
FindBin::again();
use Path::Class 'dir';
BEGIN { BEGIN {
# stuff useful locations into @INC # stuff useful locations into @INC
use Path::Class 'dir';
unshift @INC, unshift @INC,
dir($location)->parent->subdir('lib')->stringify, dir($FindBin::RealBin)->parent->subdir('lib')->stringify,
dir($location, 'lib')->stringify; dir($FindBin::RealBin, 'lib')->stringify;
} }
use App::Netdisco; use App::Netdisco;