Skip to content

Commit

Permalink
fix some problems in scala and add uplpipe agent
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiago Peczenyj committed Dec 30, 2011
1 parent 4b5594a commit 9dd25e3
Show file tree
Hide file tree
Showing 16 changed files with 1,031 additions and 43 deletions.
54 changes: 54 additions & 0 deletions Uplpipe-Agent/bin/uplpipe.daemon.pl
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',
);
9 changes: 9 additions & 0 deletions Uplpipe-Agent/dist.ini
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]
23 changes: 23 additions & 0 deletions Uplpipe-Agent/etc/uplpipe.conf
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
Loading

0 comments on commit 9dd25e3

Please sign in to comment.