Skip to content

Commit

Permalink
Add silent attribute to Mojo::Server::Morbo
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 4, 2021
1 parent f34c714 commit 46af87f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

8.73 2021-01-27
8.73 2021-02-04
- Added silent attribute to Mojo::Server::Morbo.

8.72 2021-01-26
- Deprecated Mojo::UserAgent::local_address in favor of Mojo::UserAgent::socket_options.
Expand Down
10 changes: 9 additions & 1 deletion lib/Mojo/Server/Morbo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ has backend => sub {
die qq{Can't find Morbo backend class "$backend" in \@INC. (@INC)\n};
};
has daemon => sub { Mojo::Server::Daemon->new };
has silent => 1;

sub run {
my ($self, $app) = @_;
Expand All @@ -42,7 +43,7 @@ sub _manage {
say @files == 1
? qq{File "@{[$files[0]]}" changed, restarting.}
: qq{@{[scalar @files]} files changed, restarting.}
if $ENV{MORBO_VERBOSE};
unless $self->silent;
kill 'TERM', $self->{worker} if $self->{worker};
$self->{modified} = 1;
}
Expand Down Expand Up @@ -130,6 +131,13 @@ Backend, usually a L<Mojo::Server::Morbo::Backend::Poll> object.
L<Mojo::Server::Daemon> object this server manages.
=head2 silent
my $bool = $morbo->silent;
$morbo = $morbo->silent($bool);
Disable console messages, defaults to a true value.
=head1 METHODS
L<Mojo::Server::Morbo> inherits all methods from L<Mojo::Base> and implements the following new ones.
Expand Down
4 changes: 2 additions & 2 deletions script/morbo
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ getopt
'h|help' => \my $help,
'l|listen=s' => \my @listen,
'm|mode=s' => \$ENV{MOJO_MODE},
'v|verbose' => \$ENV{MORBO_VERBOSE},
'v|verbose' => \my $verbose,
'w|watch=s' => \my @watch;

die extract_usage if $help || !(my $app = shift);
my $morbo = Mojo::Server::Morbo->new;
my $morbo = Mojo::Server::Morbo->new(silent => !$verbose);
$morbo->daemon->listen(\@listen) if @listen;
$morbo->backend->watch(\@watch) if @watch;
$morbo->run($app);
Expand Down

0 comments on commit 46af87f

Please sign in to comment.