-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f89e39e
commit 5ee71fe
Showing
2 changed files
with
75 additions
and
10 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
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,62 @@ | ||
package Tapper::Notification::Daemon; | ||
|
||
use 5.010; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Tapper::Notification; | ||
use Moose; | ||
use Tapper::Config; | ||
use Log::Log4perl; | ||
|
||
with 'MooseX::Daemonize'; | ||
|
||
|
||
after start => sub { | ||
my $self = shift; | ||
|
||
return unless $self->is_daemon; | ||
|
||
my $logconf = Tapper::Config->subconfig->{files}{log4perl_cfg}; | ||
Log::Log4perl->init($logconf); | ||
|
||
$self->initialize_server; | ||
$self->server->server_loop; | ||
} | ||
; | ||
|
||
=head2 initialize_server | ||
Initialize and start daemon according to config. | ||
=cut | ||
|
||
sub initialize_server | ||
{ | ||
my $self = shift; | ||
|
||
my $daemon = Tapper::Notification->new; | ||
$daemon->loop; | ||
} | ||
; | ||
|
||
=head2 run | ||
Frontend to subcommands: start, status, restart, stop. | ||
=cut | ||
|
||
sub run | ||
{ | ||
my $self = shift; | ||
|
||
my ($command) = @ARGV ? @ARGV : @_; | ||
return unless $command && grep /^$command$/, qw(start status restart stop); | ||
$self->$command; | ||
say $self->status_message; | ||
} | ||
; | ||
|
||
|
||
1; |