-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix some problems in scala and add uplpipe agent
- Loading branch information
Tiago Peczenyj
committed
Dec 30, 2011
1 parent
4b5594a
commit 9dd25e3
Showing
16 changed files
with
1,031 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use common::sense; | ||
use Uplpipe::Agent; | ||
use Daemon::Generic; | ||
use POE; | ||
use POE::Component::DirWatch; | ||
use Log::Log4perl; | ||
|
||
my $conf; | ||
my $agent; | ||
my $logger; | ||
|
||
sub gd_preconfig{ | ||
my ($self) = @_; | ||
$conf = Config::Tiny->read($self->{configfile}); | ||
|
||
Log::Log4perl->init($conf->{logging}); | ||
$logger = Log::Log4perl->get_logger('daemon'); | ||
$agent = Uplpipe::Agent->new(conf => $conf); | ||
|
||
return (); | ||
} | ||
|
||
sub gd_run { | ||
$logger->info("SERVER START"); | ||
|
||
my $watcher = POE::Component::DirWatch−>new( | ||
alias => 'dirwatch', | ||
directory => $conf->{daemon}->{directory}, | ||
filter => sub { $_[0] !~ /^incoming.*$/ }, | ||
file_callback => sub{ | ||
my $file = shift; $agent->process($file) | ||
}, | ||
interval => $conf->{daemon}->{interval}, | ||
); | ||
|
||
$poe_kernel−>run; | ||
$logger->info("SERVER STOP"); | ||
} | ||
|
||
sub gd_quit_event{ | ||
$logger->info("SERVER STOPPING..."); | ||
$poe_kernel->call(dirwatch_test => 'shutdown'); | ||
} | ||
|
||
sub gd_reconfig_event{ | ||
$logger->info("SERVER RECONFIGURING..."); | ||
Daemon::Generic::gd_reconfig_event(@_); | ||
} | ||
|
||
newdaemon( | ||
progname => 'uplpipe', | ||
pidfile => '/var/run/uplpipe.pid', | ||
configfile => '/etc/uplpipe.conf', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name = Uplpipe-Agent | ||
author = Tiago Peczenyj <tiago.peczenyj@gmail.com> | ||
license = Perl_5 | ||
copyright_holder = Tiago Peczenyj | ||
copyright_year = 2011 | ||
|
||
version = 0.001 | ||
|
||
[@Basic] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[logging] | ||
log4perl.category.daemon = DEBUG, LOGFILE | ||
log4perl.category.Uplpipe.Agent = ERROR, LOGFILE | ||
log4perl.appender.LOGFILE= Log::Log4perl::Appender::File | ||
log4perl.appender.LOGFILE.filename=uplpipe.log | ||
log4perl.appender.LOGFILE.layout=PatternLayout | ||
log4perl.appender.LOGFILE.layout.ConversionPattern=[%d :: %c :: %p] %m%n | ||
|
||
[amazon] | ||
aws_access_key_id=example_aws_access_key_id | ||
aws_secret_access_key=example_aws_secret_access_key | ||
retry=1 | ||
|
||
[app] | ||
bucketname=uplpipe | ||
uplpipe_url=http://localhost:7777/scala/upload/:id/download | ||
|
||
[lwp_user_agent] | ||
timeout=10 | ||
|
||
[daemon] | ||
directory=/tmp/incoming | ||
interval=10 |
Oops, something went wrong.