Codebase list libdaemon-control-perl / 0a2bc55
Imported Upstream version 0.001006 Salvatore Bonaccorso 9 years ago
11 changed file(s) with 41 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
0 0.001006 2014-06-24 SymKat <symkat@symkat.com>
1 * Allow custom reload/stop signals (hemmop)
2 * Documentation cleanup (ilmari, rwstauner)
3 * Module name POD format fixed (RT 93280)
4
05 0.001005 2014-02-19 SymKat <symkat@symkat.com>
16 * Constructor now accepts a list as well as a hashref
27 * New method added: run_command, allows multiple instances of D::C
33 - '=over 4'
44 build_requires:
55 ExtUtils::MakeMaker: 6.59
6 Test::More: 0.88
6 Test::More: '0.88'
77 configure_requires:
88 ExtUtils::MakeMaker: 6.59
99 distribution_type: module
1010 dynamic_config: 1
11 generated_by: 'Module::Install version 1.06'
11 generated_by: 'Module::Install version 1.08'
1212 license: perl
1313 meta-spec:
1414 url: http://module-build.sourceforge.net/META-spec-v1.4.html
2020 - t
2121 requires:
2222 Cwd: 0
23 File::Path: 2.08
23 File::Path: '2.08'
2424 File::Spec: 0
2525 POSIX: 0
2626 perl: 5.8.1
2727 resources:
2828 license: http://dev.perl.org/licenses/
2929 repository: git://github.com/symkat/Daemon-Control.git
30 version: 0.001005
30 version: '0.001006'
33 use strict 'vars';
44 use vars qw{$VERSION};
55 BEGIN {
6 $VERSION = '1.06';
6 $VERSION = '1.08';
77 }
88
99 # Suspend handler for "redefined" warnings
77
88 use vars qw{$VERSION @ISA $ISCORE};
99 BEGIN {
10 $VERSION = '1.06';
10 $VERSION = '1.08';
1111 @ISA = 'Module::Install::Base';
1212 $ISCORE = 1;
1313 }
55
66 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '1.06';
8 $VERSION = '1.08';
99 @ISA = 'Module::Install::Base';
1010 $ISCORE = 1;
1111 }
77
88 use vars qw{$VERSION @ISA $ISCORE};
99 BEGIN {
10 $VERSION = '1.06';
10 $VERSION = '1.08';
1111 @ISA = 'Module::Install::Base';
1212 $ISCORE = 1;
1313 }
55
66 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '1.06';
8 $VERSION = '1.08';
99 @ISA = 'Module::Install::Base';
1010 $ISCORE = 1;
1111 }
55
66 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '1.06';
8 $VERSION = '1.08';
99 @ISA = 'Module::Install::Base';
1010 $ISCORE = 1;
1111 }
55
66 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '1.06';
8 $VERSION = '1.08';
99 @ISA = qw{Module::Install::Base};
1010 $ISCORE = 1;
1111 }
3030 # This is not enforced yet, but will be some time in the next few
3131 # releases once we can make sure it won't clash with custom
3232 # Module::Install extensions.
33 $VERSION = '1.06';
33 $VERSION = '1.08';
3434
3535 # Storage for the pseudo-singleton
3636 $MAIN = undef;
77 use Cwd 'abs_path';
88 require 5.008001; # Supporting 5.8.1+
99
10 our $VERSION = '0.001005'; # 0.1.5
10 our $VERSION = '0.001006'; # 0.1.6
1111 $VERSION = eval $VERSION;
1212
1313 my @accessors = qw(
1515 uid path gid scan_name stdout_file stderr_file pid_file fork data
1616 lsb_start lsb_stop lsb_sdesc lsb_desc redirect_before_fork init_config
1717 kill_timeout umask resource_dir help init_code
18 prereq_no_process foreground
18 prereq_no_process foreground reload_signal stop_signals
1919 );
2020
2121 my $cmd_opt = "[start|stop|restart|reload|status|show_warnings|get_init_file|help]";
7373 quiet => 0,
7474 umask => 0,
7575 foreground => 0,
76 reload_signal => 'HUP',
77 stop_signals => [ qw(TERM TERM INT KILL) ],
7678 }, $class;
7779
7880 for my $accessor ( @accessors ) {
450452
451453 if ( $self->pid_running($start_pid) ) {
452454 SIGNAL:
453 foreach my $signal ( qw(TERM TERM INT KILL) ) {
455 foreach my $signal (@{ $self->stop_signals }) {
454456 $self->trace( "Sending $signal signal to pid $start_pid..." );
455457 kill $signal => $start_pid;
456458
512514 $self->read_pid;
513515
514516 if ( $self->pid && $self->pid_running ) {
515 kill "SIGHUP", $self->pid;
517 kill $self->reload_signal, $self->pid;
516518 $self->pretty_print( "Reloaded" );
517519 return 0;
518520 } else {
690692 use strict;
691693 use Daemon::Control;
692694
693 Daemon::Control->new(
695 exit Daemon::Control->new(
694696 name => "My Daemon",
695697 lsb_start => '$syslog $remote_fs',
696698 lsb_stop => '$syslog',
712714 By default C<run> will use @ARGV for the action, and exit with an LSB compatible
713715 exit code. For finer control, you can use C<run_command>, which will return
714716 the exit code, and accepts the action as an argument. This enables more programatic
715 control, as well as running multiple instances of M<Daemon::Control> from one script.
717 control, as well as running multiple instances of L<Daemon::Control> from one script.
716718
717719 my $daemon = Daemon::Control->new(
718720 ...
851853 redirecting before a double fork. This is useful when you are using a code
852854 reference and would like to leave the filehandles alone until you're in control.
853855
854 Call C<->redirect_filehandles> on the Daemon::Control instance your coderef is
856 Call C<< ->redirect_filehandles >> on the Daemon::Control instance your coderef is
855857 passed to redirect the filehandles.
856858
857859 =head2 stdout_file
982984
983985 $daemon->quiet( 1 );
984986
987 =head2 reload_signal
988
989 The signal to send to the daemon when reloading it.
990 Default signal is C<HUP>.
991
992 =head2 stop_signals
993
994 An array ref of signals that should be tried (in order) when
995 stopping the daemon.
996 Default signals are C<TERM>, C<TERM>, C<INT> and C<KILL> (yes, C<TERM>
997 is tried twice).
998
985999 =head1 METHODS
9861000
9871001 =head2 run_command
10121026 Is called when B<foreground> is given as an argument. Starts the
10131027 program or code reference and stays in the foreground -- no forking
10141028 is done, regardless of the compile-time arguments. Additionally,
1015 turns C<quiet> on to avoid showing M<Daemon::Control> output.
1029 turns C<quiet> on to avoid showing L<Daemon::Control> output.
10161030
10171031 /usr/bin/my_program_launcher.pl foreground
10181032
10321046
10331047 =head2 do_reload
10341048
1035 Is called when reload is given as an argument. Sends a HUP signal to the
1036 daemon.
1049 Is called when reload is given as an argument. Sends the signal
1050 C<reload_signal> to the daemon.
10371051
10381052 /usr/bin/my_program_launcher.pl reload
10391053