r77587 - in /trunk/libapp-daemon-perl: .cvsignore .licensizer.yml Changes Daemon.pm MANIFEST MANIFEST.SKIP META.yml Makefile.PL README adm/release debian/changelog debian/control debian/copyright t/003CmdLine.t
carnil at users.alioth.debian.org
carnil at users.alioth.debian.org
Tue Jul 19 05:45:07 UTC 2011
Author: carnil
Date: Tue Jul 19 05:45:06 2011
New Revision: 77587
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=77587
Log:
* New upstream release
* debian/copyright: Update copyright years for upstream files and
debian/* packaging.
* debian/control: Add libsysadm-install-perl (>= 0.37) to Build-
Depends-Indep.
Added:
trunk/libapp-daemon-perl/.licensizer.yml
- copied unchanged from r77586, branches/upstream/libapp-daemon-perl/current/.licensizer.yml
trunk/libapp-daemon-perl/MANIFEST.SKIP
- copied unchanged from r77586, branches/upstream/libapp-daemon-perl/current/MANIFEST.SKIP
trunk/libapp-daemon-perl/t/003CmdLine.t
- copied unchanged from r77586, branches/upstream/libapp-daemon-perl/current/t/003CmdLine.t
Removed:
trunk/libapp-daemon-perl/.cvsignore
Modified:
trunk/libapp-daemon-perl/Changes
trunk/libapp-daemon-perl/Daemon.pm
trunk/libapp-daemon-perl/MANIFEST
trunk/libapp-daemon-perl/META.yml
trunk/libapp-daemon-perl/Makefile.PL
trunk/libapp-daemon-perl/README
trunk/libapp-daemon-perl/adm/release
trunk/libapp-daemon-perl/debian/changelog
trunk/libapp-daemon-perl/debian/control
trunk/libapp-daemon-perl/debian/copyright
Modified: trunk/libapp-daemon-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-daemon-perl/Changes?rev=77587&op=diff
==============================================================================
--- trunk/libapp-daemon-perl/Changes (original)
+++ trunk/libapp-daemon-perl/Changes Tue Jul 19 05:45:06 2011
@@ -1,4 +1,15 @@
Revision history for Perl extension App::Daemon.
+
+0.12 (07/18/2011)
+ (ms) 'status' now doesn't write to the logfile (suggested by Brian Pitts)
+ (ms) 'stop' now verifies if the process is still up, and retries
+ $App::Daemon::kill_retries times (defaults to 3) times, with
+ 1-second sleeps in between.
+ (ms) Upon successful 'stop', pid file now gets removed (suggested by
+ Brian Pitts)
+ (ms) 'status' now triggers exit codes
+ in compliance with http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html (suggested by Brian Pitts)
+ (ms) using SIGTERM now instead of SIGINT to terminate a process
0.11 (08/28/2010)
(ms) Fixed test suite.
Modified: trunk/libapp-daemon-perl/Daemon.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-daemon-perl/Daemon.pm?rev=77587&op=diff
==============================================================================
--- trunk/libapp-daemon-perl/Daemon.pm (original)
+++ trunk/libapp-daemon-perl/Daemon.pm Tue Jul 19 05:45:06 2011
@@ -2,11 +2,10 @@
use strict;
use warnings;
-our $VERSION = '0.11';
+our $VERSION = '0.12';
use Getopt::Std;
use Pod::Usage;
-use Log::Log4perl qw(:easy);
use File::Basename;
use Proc::ProcessTable;
use Log::Log4perl qw(:easy);
@@ -17,11 +16,21 @@
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(daemonize cmd_line_parse detach);
+use constant LSB_OK => 0;
+use constant LSB_DEAD_PID_EXISTS => 1;
+use constant LSB_DEAD_LOCK_EXISTS => 2;
+use constant LSB_NOT_RUNNING => 3;
+use constant LSB_UNKNOWN => 4;
+use constant ALREADY_RUNNING => 150;
+
our ($pidfile, $logfile, $l4p_conf, $as_user, $background,
$loglevel, $action, $appname);
$action = "";
$appname = appname();
+our $kill_retries = 3;
+our $kill_sig = SIGTERM; # maps to 15 via POSIX.pm
+
###########################################
sub cmd_line_parse {
###########################################
@@ -80,6 +89,8 @@
if( Log::Log4perl->initialized() ) {
DEBUG "Log4perl already initialized, doing nothing";
+ } elsif( $action eq "status" ) {
+ Log::Log4perl->easy_init( $loglevel );
} elsif( $l4p_conf ) {
Log::Log4perl->init( $l4p_conf );
} elsif( $logfile ) {
@@ -111,33 +122,53 @@
}
if($action eq "status") {
- status();
- exit 0;
+ exit status();
}
if($action eq "stop" or $action eq "restart") {
+ my $exit_code = LSB_NOT_RUNNING;
+
if(-f $pidfile) {
my $pid = pid_file_read();
if(kill 0, $pid) {
- kill 2, $pid;
+ kill $kill_sig, $pid;
+ my $killed = 0;
+ for (1..$kill_retries) {
+ if(!kill 0, $pid) {
+ INFO "Process $pid stopped successfully.";
+ unlink $pidfile or die "Can't remove $pidfile ($!)";
+ $exit_code = LSB_OK;
+ $killed++;
+ last;
+ }
+ INFO "Process $pid still running, waiting ...";
+ sleep 1;
+ }
+ if(! $killed) {
+ ERROR "Process $pid still up, out of retries, giving up.";
+ $exit_code = LSB_DEAD_PID_EXISTS;
+ }
} else {
ERROR "Process $pid not running\n";
unlink $pidfile or die "Can't remove $pidfile ($!)";
+ $exit_code = LSB_NOT_RUNNING;
}
} else {
ERROR "According to my pidfile, there's no instance ",
"of me running.";
- }
+ $exit_code = LSB_NOT_RUNNING;
+ }
+
if($action eq "restart") {
sleep 1;
} else {
- INFO "Process $$ stopped by request.";
- exit 0;
+ exit $exit_code;
}
}
if ( my $num = pid_file_process_running() ) {
- LOGDIE "Already running: $num (pidfile=$pidfile)\n";
+ LOGWARN "Already running: $num (pidfile=$pidfile)\n";
+ exit ALREADY_RUNNING;
}
if( $background ) {
@@ -220,20 +251,35 @@
###########################################
sub status {
###########################################
+
+ # Define exit codes according to
+ # http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
+ my $exit_code = LSB_UNKNOWN;
+
print "Pid file: $pidfile\n";
if(-f $pidfile) {
my $pid = pid_file_read();
+ my $running = process_running($pid);
print "Pid in file: $pid\n";
- print "Running: ", process_running($pid) ? "yes" : "no", "\n";
+ print "Running: ", $running ? "yes" : "no", "\n";
+ if($running) {
+ # see above
+ $exit_code = LSB_OK;
+ } else {
+ # see above
+ $exit_code = LSB_DEAD_PID_EXISTS;
+ }
} else {
print "No pidfile found\n";
+ $exit_code = LSB_NOT_RUNNING;
}
my @cmdlines = processes_running_by_name( $appname );
print "Name match: ", scalar @cmdlines, "\n";
for(@cmdlines) {
print " ", $_, "\n";
}
- return 1;
+
+ return $exit_code;
}
@@ -449,9 +495,17 @@
=item stop
-will find the daemon's PID in the pidfile and send it a kill signal. It
-won't verify if this actually shut down the daemon or if it's immune to
-the kill signal.
+will find the daemon's PID in the pidfile and send it a SIGTERM signal. It
+will verify $App::Daemon::kill_retries times if the process is still alive,
+with 1-second sleeps in between.
+
+To have App::Daemon send a different signal than SIGTERM (e.g., SIGINT), set
+
+ use POSIX;
+ $App::Daemon::kill_sig = SIGINT;
+
+Note that his requires the numerial value (SIGINT via POSIX.pm), not a
+string like "SIGINT".
=item status
@@ -482,6 +536,26 @@
Pid in file: 14914
Running: no
Name match: 0
+
+The status commands exit code complies with
+
+ http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
+
+and returns
+
+ 0: if the process is up and running
+ 1: the process is dead but the pid file still exists
+ 3: the process is not running
+
+These constants are defined within App::Daemon to help writing test
+scripts:
+
+ use constant LSB_OK => 0;
+ use constant LSB_DEAD_PID_EXISTS => 1;
+ use constant LSB_DEAD_LOCK_EXISTS => 2;
+ use constant LSB_NOT_RUNNING => 3;
+ use constant LSB_UNKNOWN => 4;
+ use constant ALREADY_RUNNING => 150;
=back
@@ -601,8 +675,8 @@
=head1 AUTHOR
-Mike Schilli, cpan at perlmeister.com
-
+ 2011, Mike Schilli <cpan at perlmeister.com>
+
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2008 by Mike Schilli
@@ -611,4 +685,11 @@
it under the same terms as Perl itself, either Perl version 5.8.5 or,
at your option, any later version of Perl 5 you may have available.
-=cut
+=cut
+
+=head1 LICENSE
+
+Copyright 2011 by Mike Schilli, all rights reserved.
+This program is free software, you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
Modified: trunk/libapp-daemon-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-daemon-perl/MANIFEST?rev=77587&op=diff
==============================================================================
--- trunk/libapp-daemon-perl/MANIFEST (original)
+++ trunk/libapp-daemon-perl/MANIFEST Tue Jul 19 05:45:06 2011
@@ -1,4 +1,4 @@
-.cvsignore
+.licensizer.yml
adm/release
Changes
Daemon.pm
@@ -6,7 +6,9 @@
eg/test-detach
Makefile.PL
MANIFEST
+MANIFEST.SKIP
README
t/001Basic.t
t/002Params.t
+t/003CmdLine.t
META.yml Module meta-data (added by MakeMaker)
Modified: trunk/libapp-daemon-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-daemon-perl/META.yml?rev=77587&op=diff
==============================================================================
--- trunk/libapp-daemon-perl/META.yml (original)
+++ trunk/libapp-daemon-perl/META.yml Tue Jul 19 05:45:06 2011
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: App-Daemon
-version: 0.11
+version: 0.12
abstract: Start an Application as a Daemon
author:
- Mike Schilli <m at perlmeister.com>
@@ -18,6 +18,7 @@
Log::Log4perl: 1.0
Pod::Usage: 0
Proc::ProcessTable: 0
+ Sysadm::Install: 0.37
Test::More: 0
resources:
repository: http://github.com/mschilli/app-daemon
@@ -25,7 +26,7 @@
directory:
- t
- inc
-generated_by: ExtUtils::MakeMaker version 6.55_02
+generated_by: ExtUtils::MakeMaker version 6.56
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
Modified: trunk/libapp-daemon-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-daemon-perl/Makefile.PL?rev=77587&op=diff
==============================================================================
--- trunk/libapp-daemon-perl/Makefile.PL (original)
+++ trunk/libapp-daemon-perl/Makefile.PL Tue Jul 19 05:45:06 2011
@@ -22,6 +22,7 @@
File::Basename => 0,
Test::More => 0,
File::Temp => 0,
+ Sysadm::Install => 0.37,
}, # e.g., Module::Name => 1.1
$ExtUtils::MakeMaker::VERSION >= 6.50 ? (%$meta_merge) : (),
($] >= 5.005 ? ## Add these new keywords supported since 5.005
Modified: trunk/libapp-daemon-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-daemon-perl/README?rev=77587&op=diff
==============================================================================
--- trunk/libapp-daemon-perl/README (original)
+++ trunk/libapp-daemon-perl/README Tue Jul 19 05:45:06 2011
@@ -1,5 +1,5 @@
######################################################################
- App::Daemon 0.11
+ App::Daemon 0.12
######################################################################
NAME
@@ -73,9 +73,18 @@
program is run in foreground mode for testing purposes.
stop
- will find the daemon's PID in the pidfile and send it a kill signal.
- It won't verify if this actually shut down the daemon or if it's
- immune to the kill signal.
+ will find the daemon's PID in the pidfile and send it a SIGTERM
+ signal. It will verify $App::Daemon::kill_retries times if the
+ process is still alive, with 1-second sleeps in between.
+
+ To have App::Daemon send a different signal than SIGTERM (e.g.,
+ SIGINT), set
+
+ use POSIX;
+ $App::Daemon::kill_sig = SIGINT;
+
+ Note that his requires the numerial value (SIGINT via POSIX.pm), not
+ a string like "SIGINT".
status
will print out diagnostics on what the status of the daemon is.
@@ -105,6 +114,26 @@
Pid in file: 14914
Running: no
Name match: 0
+
+ The status commands exit code complies with
+
+ http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
+
+ and returns
+
+ 0: if the process is up and running
+ 1: the process is dead but the pid file still exists
+ 3: the process is not running
+
+ These constants are defined within App::Daemon to help writing test
+ scripts:
+
+ use constant LSB_OK => 0;
+ use constant LSB_DEAD_PID_EXISTS => 1;
+ use constant LSB_DEAD_LOCK_EXISTS => 2;
+ use constant LSB_NOT_RUNNING => 3;
+ use constant LSB_UNKNOWN => 4;
+ use constant ALREADY_RUNNING => 150;
Command Line Options
-X Foreground mode. Log messages go to the screen.
@@ -204,8 +233,8 @@
shell prompt immediately.
AUTHOR
- Mike Schilli, cpan at perlmeister.com
-
+ 2011, Mike Schilli <cpan at perlmeister.com>
+
COPYRIGHT AND LICENSE
Copyright (C) 2008 by Mike Schilli
@@ -213,3 +242,8 @@
under the same terms as Perl itself, either Perl version 5.8.5 or, at
your option, any later version of Perl 5 you may have available.
+LICENSE
+ Copyright 2011 by Mike Schilli, all rights reserved. This program is
+ free software, you can redistribute it and/or modify it under the same
+ terms as Perl itself.
+
Modified: trunk/libapp-daemon-perl/adm/release
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-daemon-perl/adm/release?rev=77587&op=diff
==============================================================================
--- trunk/libapp-daemon-perl/adm/release (original)
+++ trunk/libapp-daemon-perl/adm/release Tue Jul 19 05:45:06 2011
@@ -5,4 +5,5 @@
# Available at http://perlmeister.com/scripts
use lib "$ENV{HOME}/perl-modules";
use ModDevUtils;
+system("licensizer");
ModDevUtils::release(0) or exit 0;
Modified: trunk/libapp-daemon-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-daemon-perl/debian/changelog?rev=77587&op=diff
==============================================================================
--- trunk/libapp-daemon-perl/debian/changelog (original)
+++ trunk/libapp-daemon-perl/debian/changelog Tue Jul 19 05:45:06 2011
@@ -1,8 +1,13 @@
-libapp-daemon-perl (0.11-2) UNRELEASED; urgency=low
+libapp-daemon-perl (0.12-1) UNRELEASED; urgency=low
+ * New upstream release
+ * debian/copyright: Update copyright years for upstream files and
+ debian/* packaging.
* Email change: Salvatore Bonaccorso -> carnil at debian.org
+ * debian/control: Add libsysadm-install-perl (>= 0.37) to Build-
+ Depends-Indep.
- -- Salvatore Bonaccorso <carnil at debian.org> Sun, 10 Oct 2010 15:02:27 +0200
+ -- Salvatore Bonaccorso <carnil at debian.org> Tue, 19 Jul 2011 07:44:58 +0200
libapp-daemon-perl (0.11-1) unstable; urgency=low
Modified: trunk/libapp-daemon-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-daemon-perl/debian/control?rev=77587&op=diff
==============================================================================
--- trunk/libapp-daemon-perl/debian/control (original)
+++ trunk/libapp-daemon-perl/debian/control Tue Jul 19 05:45:06 2011
@@ -3,7 +3,7 @@
Priority: optional
Build-Depends: debhelper (>= 7)
Build-Depends-Indep: libfile-pid-perl, liblog-log4perl-perl,
- libproc-processtable-perl, perl
+ libproc-processtable-perl, libsysadm-install-perl (>= 0.37), perl
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
Uploaders: Xavier Oswald <xoswald at debian.org>,
Brian Cassidy <brian.cassidy at gmail.com>,
Modified: trunk/libapp-daemon-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libapp-daemon-perl/debian/copyright?rev=77587&op=diff
==============================================================================
--- trunk/libapp-daemon-perl/debian/copyright (original)
+++ trunk/libapp-daemon-perl/debian/copyright Tue Jul 19 05:45:06 2011
@@ -4,11 +4,11 @@
Name: App-Daemon
Files: *
-Copyright: 2008, Mike Schilli <m at perlmeister.com>
+Copyright: 2008-2011, Mike Schilli <m at perlmeister.com>
License: Artistic or GPL-1+
Files: debian/*
-Copyright: 2009, 2010, Salvatore Bonaccorso <carnil at debian.org>
+Copyright: 2009, 2010, 2011, Salvatore Bonaccorso <carnil at debian.org>
2009, Brian Cassidy <brian.cassidy at gmail.com>
2009, Xavier Oswald <xoswald at debian.org>
License: Artistic or GPL-1+
More information about the Pkg-perl-cvs-commits
mailing list