[SCM] libmessage-passing-perl Debian packaging branch, master, updated. debian/0.111-3-14-g44f6e88

Tomas Doran bobtfish at bobtfish.net
Mon May 6 11:56:50 UTC 2013


The following commit has been merged in the master branch:
commit f454fc4cd26cffd8f8a811426f9afce013e851ff
Author: Tomas Doran <bobtfish at bobtfish.net>
Date:   Sun Apr 15 17:37:21 2012 +0100

    Pid file support

diff --git a/Changes b/Changes
index bc6b13b..feaa188 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,7 @@
+    - Support a --daemonize option in logstash scripts.
+
+    - Support a --pid_file option in logstash scripts.
+
     - Allow inputs to coerce a hash in output_to to an output,
       which is more verbose than the DSL, but also allows you
       to setup simple output chains from a simple data structure
diff --git a/lib/Log/Stash.pm b/lib/Log/Stash.pm
index f49df2e..60a29ca 100644
--- a/lib/Log/Stash.pm
+++ b/lib/Log/Stash.pm
@@ -66,6 +66,11 @@ has daemonize => (
 sub deamonize_if_needed {
     my ($self) = @_;
     my $daemon = $self->daemonize;
+    my $fh;
+    if ($self->_has_pid_file) {
+        open($fh, '>', $self->pid_file)
+            or confess("Could not open pid file '". $self->pid_file . "'");
+    }
     if ($daemon) {
         fork && exit;
         POSIX::setsid();
@@ -73,8 +78,18 @@ sub deamonize_if_needed {
         chdir '/';
         umask 0;
     }
+    if ($fh) {
+        print $fh $$ . "\n";
+        close($fh);
+    }
 }
 
+has pid_file => (
+    isa => 'Str',
+    is => 'ro',
+    predicate => '_has_pid_file',
+);
+
 sub start {
     my $class = shift;
     my $instance = $class->new_with_options(@_);

-- 
libmessage-passing-perl Debian packaging



More information about the Pkg-perl-cvs-commits mailing list