Hello community, here is the log from the commit of package perl-Mojolicious for openSUSE:Factory checked in at 2017-07-17 09:01:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Mojolicious (Old) and /work/SRC/openSUSE:Factory/.perl-Mojolicious.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Mojolicious" Mon Jul 17 09:01:52 2017 rev:70 rq:509619 version:7.36 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Mojolicious/perl-Mojolicious.changes 2017-06-17 10:21:05.663789581 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Mojolicious.new/perl-Mojolicious.changes 2017-07-17 09:01:57.405689460 +0200 @@ -1,0 +2,34 @@ +Wed Jul 12 05:47:03 UTC 2017 - [email protected] + +- updated to 7.36 + see /usr/share/doc/packages/perl-Mojolicious/Changes + + 7.36 2017-07-09 + - Fixed basename method in Mojo::File to work with relative paths. (jberger) + - Fixed a bug where Mojo::Log could not correctly identify if it was deployed + with systemd. + - Fixed Mojo::HelloWorld to actually be a Mojolicious subclass. + + 7.35 2017-07-05 + - Removed deprecated watch attribute from Mojo::Server::Morbo. + - Added spare attribute to Mojo::Server::Prefork. + - Added -s option to prefork command. + - Added fd option to Mojo::IOLoop::Server::listen. + - Added fd parameter to Mojo::Server::Daemon::listen. + - Added spare setting to Hypnotoad. + - Increased default graceful_timeout from 20 to 60 seconds and + heartbeat_timeout from 20 to 30 seconds in Mojo::Server::Prefork. + +------------------------------------------------------------------- +Tue Jul 4 05:53:43 UTC 2017 - [email protected] + +- updated to 7.34 + see /usr/share/doc/packages/perl-Mojolicious/Changes + + 7.34 2017-07-02 + - Added short attribute to Mojo::Log. + - Improved Mojo::Log to print log messages without timestamps to STDERR when + deployed with systemd. + - Improved Mojo::DOM performance slightly. + +------------------------------------------------------------------- Old: ---- Mojolicious-7.33.tar.gz New: ---- Mojolicious-7.36.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Mojolicious.spec ++++++ --- /var/tmp/diff_new_pack.Rrkif0/_old 2017-07-17 09:01:57.929615683 +0200 +++ /var/tmp/diff_new_pack.Rrkif0/_new 2017-07-17 09:01:57.933615120 +0200 @@ -17,7 +17,7 @@ Name: perl-Mojolicious -Version: 7.33 +Version: 7.36 Release: 0 %define cpan_name Mojolicious Summary: Real-time web framework ++++++ Mojolicious-7.33.tar.gz -> Mojolicious-7.36.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/Changes new/Mojolicious-7.36/Changes --- old/Mojolicious-7.33/Changes 2017-06-05 17:05:19.000000000 +0200 +++ new/Mojolicious-7.36/Changes 2017-07-09 19:05:11.000000000 +0200 @@ -1,7 +1,29 @@ +7.36 2017-07-09 + - Fixed basename method in Mojo::File to work with relative paths. (jberger) + - Fixed a bug where Mojo::Log could not correctly identify if it was deployed + with systemd. + - Fixed Mojo::HelloWorld to actually be a Mojolicious subclass. + +7.35 2017-07-05 + - Removed deprecated watch attribute from Mojo::Server::Morbo. + - Added spare attribute to Mojo::Server::Prefork. + - Added -s option to prefork command. + - Added fd option to Mojo::IOLoop::Server::listen. + - Added fd parameter to Mojo::Server::Daemon::listen. + - Added spare setting to Hypnotoad. + - Increased default graceful_timeout from 20 to 60 seconds and + heartbeat_timeout from 20 to 30 seconds in Mojo::Server::Prefork. + +7.34 2017-07-02 + - Added short attribute to Mojo::Log. + - Improved Mojo::Log to print log messages without timestamps to STDERR when + deployed with systemd. + - Improved Mojo::DOM performance slightly. + 7.33 2017-06-05 - Added EXPERIMENTAL support for :matches pseudo-class and :not pseudo-class - with compount selectors to Mojo::DOM::CSS. + with compound selectors to Mojo::DOM::CSS. - Fixed a few form element value extraction bugs in Mojo::DOM. - Fixed version command to use the new MetaCPAN API, since the old one got shut down. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/META.json new/Mojolicious-7.36/META.json --- old/Mojolicious-7.33/META.json 2017-06-06 00:13:11.000000000 +0200 +++ new/Mojolicious-7.36/META.json 2017-07-10 09:47:25.000000000 +0200 @@ -4,7 +4,7 @@ "Sebastian Riedel <[email protected]>" ], "dynamic_config" : 0, - "generated_by" : "ExtUtils::MakeMaker version 7.28, CPAN::Meta::Converter version 2.150010", + "generated_by" : "ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010", "license" : [ "artistic_2" ], @@ -58,6 +58,6 @@ }, "x_IRC" : "irc://irc.perl.org/#mojo" }, - "version" : "7.33", + "version" : "7.36", "x_serialization_backend" : "JSON::PP version 2.94" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/META.yml new/Mojolicious-7.36/META.yml --- old/Mojolicious-7.33/META.yml 2017-06-06 00:13:11.000000000 +0200 +++ new/Mojolicious-7.36/META.yml 2017-07-10 09:47:24.000000000 +0200 @@ -7,7 +7,7 @@ configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 -generated_by: 'ExtUtils::MakeMaker version 7.28, CPAN::Meta::Converter version 2.150010' +generated_by: 'ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010' license: artistic_2 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -31,5 +31,5 @@ homepage: http://mojolicious.org license: http://www.opensource.org/licenses/artistic-license-2.0 repository: https://github.com/kraih/mojo.git -version: '7.33' +version: '7.36' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/ByteStream.pm new/Mojolicious-7.36/lib/Mojo/ByteStream.pm --- old/Mojolicious-7.33/lib/Mojo/ByteStream.pm 2017-04-12 17:03:22.000000000 +0200 +++ new/Mojolicious-7.36/lib/Mojo/ByteStream.pm 2017-06-24 15:01:30.000000000 +0200 @@ -137,7 +137,7 @@ my $stream2 = $stream->clone; -Clone bytestream. +Return a new L<Mojo::ByteStream> object cloned from this bytestream. =head2 decamelize diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/Content/MultiPart.pm new/Mojolicious-7.36/lib/Mojo/Content/MultiPart.pm --- old/Mojolicious-7.33/lib/Mojo/Content/MultiPart.pm 2017-01-26 00:07:47.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojo/Content/MultiPart.pm 2017-07-05 19:10:27.000000000 +0200 @@ -272,7 +272,8 @@ my $clone = $multi->clone; -Clone content if possible, otherwise return C<undef>. +Return a new L<Mojo::Content::MultiPart> object cloned from this content if +possible, otherwise return C<undef>. =head2 get_body_chunk diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/Content/Single.pm new/Mojolicious-7.36/lib/Mojo/Content/Single.pm --- old/Mojolicious-7.33/lib/Mojo/Content/Single.pm 2017-01-26 00:00:28.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojo/Content/Single.pm 2017-07-05 19:10:27.000000000 +0200 @@ -135,7 +135,8 @@ my $clone = $single->clone; -Clone content if possible, otherwise return C<undef>. +Return a new L<Mojo::Content::Single> object cloned from this content if +possible, otherwise return C<undef>. =head2 get_body_chunk diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/Content.pm new/Mojolicious-7.36/lib/Mojo/Content.pm --- old/Mojolicious-7.33/lib/Mojo/Content.pm 2016-07-21 22:36:32.000000000 +0200 +++ new/Mojolicious-7.36/lib/Mojo/Content.pm 2017-06-24 15:01:30.000000000 +0200 @@ -445,7 +445,8 @@ my $clone = $content->clone; -Clone content if possible, otherwise return C<undef>. +Return a new L<Mojo::Content> object cloned from this content if possible, +otherwise return C<undef>. =head2 generate_body_chunk diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/DOM.pm new/Mojolicious-7.36/lib/Mojo/DOM.pm --- old/Mojolicious-7.33/lib/Mojo/DOM.pm 2017-06-05 17:04:52.000000000 +0200 +++ new/Mojolicious-7.36/lib/Mojo/DOM.pm 2017-07-01 14:14:46.000000000 +0200 @@ -15,9 +15,9 @@ use Mojo::DOM::HTML; use Scalar::Util qw(blessed weaken); -sub all_text { _text([_nodes(shift->tree)], 1) } +sub all_text { _text(_nodes(shift->tree), 1) } -sub ancestors { _select($_[0]->_collect($_[0]->_ancestors), $_[1]) } +sub ancestors { _select($_[0]->_collect([$_[0]->_ancestors]), $_[1]) } sub append { shift->_add(1, @_) } sub append_content { shift->_content(1, 0, @_) } @@ -57,7 +57,7 @@ if ($type eq 'root' || $type eq 'tag') { return $self->_content(0, 1, @_) if @_; my $html = Mojo::DOM::HTML->new(xml => $self->xml); - return join '', map { $html->tree($_)->render } _nodes($self->tree); + return join '', map { $html->tree($_)->render } @{_nodes($self->tree)}; } return $self->tree->[1] unless @_; @@ -67,10 +67,10 @@ sub descendant_nodes { $_[0]->_collect(_all(_nodes($_[0]->tree))) } -sub find { $_[0]->_collect(@{$_[0]->_css->select($_[1])}) } +sub find { $_[0]->_collect($_[0]->_css->select($_[1])) } -sub following { _select($_[0]->_collect(@{$_[0]->_siblings(1)->[1]}), $_[1]) } -sub following_nodes { $_[0]->_collect(@{$_[0]->_siblings->[1]}) } +sub following { _select($_[0]->_collect($_[0]->_siblings(1, 1)), $_[1]) } +sub following_nodes { $_[0]->_collect($_[0]->_siblings(0, 1)) } sub matches { shift->_css->matches(@_) } @@ -100,32 +100,32 @@ return @_ ? $self->parse(@_) : $self; } -sub next { $_[0]->_maybe($_[0]->_siblings(1, 0)->[1]) } -sub next_node { $_[0]->_maybe($_[0]->_siblings(0, 0)->[1]) } +sub next { $_[0]->_maybe($_[0]->_siblings(1, 1, 0)) } +sub next_node { $_[0]->_maybe($_[0]->_siblings(0, 1, 0)) } sub parent { my $self = shift; - return undef if $self->tree->[0] eq 'root'; - return $self->_build($self->_parent, $self->xml); + return undef if (my $tree = $self->tree)->[0] eq 'root'; + return $self->_build(_parent($tree), $self->xml); } sub parse { shift->_delegate(parse => @_) } -sub preceding { _select($_[0]->_collect(@{$_[0]->_siblings(1)->[0]}), $_[1]) } -sub preceding_nodes { $_[0]->_collect(@{$_[0]->_siblings->[0]}) } +sub preceding { _select($_[0]->_collect($_[0]->_siblings(1, 0)), $_[1]) } +sub preceding_nodes { $_[0]->_collect($_[0]->_siblings(0)) } sub prepend { shift->_add(0, @_) } sub prepend_content { shift->_content(0, 0, @_) } -sub previous { $_[0]->_maybe($_[0]->_siblings(1, -1)->[0]) } -sub previous_node { $_[0]->_maybe($_[0]->_siblings(0, -1)->[0]) } +sub previous { $_[0]->_maybe($_[0]->_siblings(1, 0, -1)) } +sub previous_node { $_[0]->_maybe($_[0]->_siblings(0, 0, -1)) } sub remove { shift->replace('') } sub replace { my ($self, $new) = @_; return $self->parse($new) if (my $tree = $self->tree)->[0] eq 'root'; - return $self->_replace($self->_parent, $tree, _nodes($self->_parse($new))); + return $self->_replace(_parent($tree), $tree, _nodes($self->_parse($new))); } sub root { @@ -150,7 +150,7 @@ sub tap { shift->Mojo::Base::tap(@_) } -sub text { _text([_nodes(shift->tree)], 0) } +sub text { _text(_nodes(shift->tree), 0) } sub to_string { shift->_delegate('render') } @@ -188,21 +188,23 @@ return $self if (my $tree = $self->tree)->[0] eq 'root'; - my $parent = $self->_parent; + my $parent = _parent($tree); splice @$parent, _offset($parent, $tree) + $offset, 0, - _link($parent, _nodes($self->_parse($new))); + @{_link($parent, _nodes($self->_parse($new)))}; return $self; } sub _all { - map { $_->[0] eq 'tag' ? ($_, _all(_nodes($_))) : ($_) } @_; + my $nodes = shift; + @$nodes = map { $_->[0] eq 'tag' ? ($_, @{_all(_nodes($_))}) : ($_) } @$nodes; + return $nodes; } sub _ancestors { my ($self, $root) = @_; - return () unless my $tree = $self->_parent; + return () unless my $tree = _parent($self->tree); my @ancestors; do { push @ancestors, $tree } while ($tree->[0] eq 'tag') && ($tree = $tree->[3]); @@ -212,9 +214,9 @@ sub _build { shift->new->tree(shift)->xml(shift) } sub _collect { - my $self = shift; - my $xml = $self->xml; - return Mojo::Collection->new(map { $self->_build($_, $xml) } @_); + my ($self, $nodes) = (shift, shift // []); + my $xml = $self->xml; + return Mojo::Collection->new(map { $self->_build($_, $xml) } @$nodes); } sub _content { @@ -228,7 +230,7 @@ $start = $start ? ($#$tree + 1) : _start($tree); $offset = $offset ? $#$tree : 0; - splice @$tree, $start, $offset, _link($tree, _nodes($self->_parse($new))); + splice @$tree, $start, $offset, @{_link($tree, _nodes($self->_parse($new)))}; return $self; } @@ -243,16 +245,16 @@ } sub _link { - my ($parent, @children) = @_; + my ($parent, $children) = @_; # Link parent to children - for my $node (@children) { + for my $node (@$children) { my $offset = $node->[0] eq 'tag' ? 3 : 2; $node->[$offset] = $parent; weaken $node->[$offset]; } - return @children; + return $children; } sub _maybe { $_[1] ? $_[0]->_build($_[1], $_[0]->xml) : undef } @@ -260,7 +262,7 @@ sub _nodes { return () unless my $tree = shift; my @nodes = @$tree[_start($tree) .. $#$tree]; - return shift() ? grep { $_->[0] eq 'tag' } @nodes : @nodes; + return shift() ? [grep { $_->[0] eq 'tag' } @nodes] : \@nodes; } sub _offset { @@ -270,36 +272,33 @@ return $i; } -sub _parent { $_[0]->tree->[$_[0]->type eq 'tag' ? 3 : 2] } +sub _parent { $_[0]->[$_[0][0] eq 'tag' ? 3 : 2] } sub _parse { Mojo::DOM::HTML->new(xml => shift->xml)->parse(shift)->tree } sub _replace { - my ($self, $parent, $child, @nodes) = @_; - splice @$parent, _offset($parent, $child), 1, _link($parent, @nodes); + my ($self, $parent, $child, $nodes) = @_; + splice @$parent, _offset($parent, $child), 1, @{_link($parent, $nodes)}; return $self->parent; } -sub _select { - my ($collection, $selector) = @_; - return $collection unless $selector; - return $collection->new(grep { $_->matches($selector) } @$collection); -} +sub _select { $_[1] ? $_[0]->grep(matches => $_[1]) : $_[0] } sub _siblings { - my ($self, $tags, $i) = @_; + my ($self, $tags, $tail, $i) = @_; - return [] unless my $parent = $self->parent; + return defined $i ? undef : [] if (my $tree = $self->tree)->[0] eq 'root'; - my $tree = $self->tree; - my (@before, @after, $match); - for my $node (_nodes($parent->tree)) { - ++$match and next if !$match && $node eq $tree; - next if $tags && $node->[0] ne 'tag'; - $match ? push @after, $node : push @before, $node; - } + my $nodes = _nodes(_parent($tree)); + my $match = -1; + defined($match++) and $_ eq $tree and last for @$nodes; + + if ($tail) { splice @$nodes, 0, $match + 1 } + else { splice @$nodes, $match, ($#$nodes + 1) - $match } + + @$nodes = grep { $_->[0] eq 'tag' } @$nodes if $tags; - return defined $i ? [$before[$i], $after[$i]] : [\@before, \@after]; + return defined $i ? $i == -1 && !@$nodes ? undef : $nodes->[$i] : $nodes; } sub _start { $_[0][0] eq 'root' ? 1 : 4 } @@ -317,7 +316,7 @@ } # Nested tag - elsif ($type eq 'tag' && $all) { unshift @$nodes, _nodes($node) } + elsif ($type eq 'tag' && $all) { unshift @$nodes, @{_nodes($node)} } } return $text; @@ -332,19 +331,19 @@ # Find innermost tag my $current; my $first = $new = $self->_parse($new); - $current = $first while $first = (_nodes($first, 1))[0]; + $current = $first while $first = _nodes($first, 1)->[0]; return $self unless $current; # Wrap content if ($content) { - push @$current, _link($current, _nodes($tree)); - splice @$tree, _start($tree), $#$tree, _link($tree, _nodes($new)); + push @$current, @{_link($current, _nodes($tree))}; + splice @$tree, _start($tree), $#$tree, @{_link($tree, _nodes($new))}; return $self; } # Wrap element - $self->_replace($self->_parent, $tree, _nodes($new)); - push @$current, _link($current, $tree); + $self->_replace(_parent($tree), $tree, _nodes($new)); + push @$current, @{_link($current, [$tree])}; return $self; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/File.pm new/Mojolicious-7.36/lib/Mojo/File.pm --- old/Mojolicious-7.33/lib/Mojo/File.pm 2017-03-07 22:17:16.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojo/File.pm 2017-07-07 10:46:59.000000000 +0200 @@ -21,7 +21,7 @@ our @EXPORT_OK = ('path', 'tempdir', 'tempfile'); -sub basename { File::Basename::basename ${$_[0]}, @_ } +sub basename { File::Basename::basename ${shift()}, @_ } sub child { $_[0]->new(@_) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/Headers.pm new/Mojolicious-7.36/lib/Mojo/Headers.pm --- old/Mojolicious-7.33/lib/Mojo/Headers.pm 2016-10-22 18:58:03.000000000 +0200 +++ new/Mojolicious-7.36/lib/Mojo/Headers.pm 2017-06-24 15:01:30.000000000 +0200 @@ -298,7 +298,7 @@ my $clone = $headers->clone; -Clone headers. +Return a new L<Mojo::Headers> object cloned from these headers. =head2 connection diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/HelloWorld.pm new/Mojolicious-7.36/lib/Mojo/HelloWorld.pm --- old/Mojolicious-7.33/lib/Mojo/HelloWorld.pm 2016-07-19 02:38:18.000000000 +0200 +++ new/Mojolicious-7.36/lib/Mojo/HelloWorld.pm 2017-07-08 13:22:20.000000000 +0200 @@ -1,9 +1,12 @@ package Mojo::HelloWorld; -use Mojolicious::Lite; +use Mojo::Base 'Mojolicious'; -app->log->level('error')->path(undef); - -any '/*whatever' => {whatever => '', text => 'Your Mojo is working!'}; +sub startup { + my $self = shift; + $self->log->level('error')->path(undef); + $self->routes->any( + '/*whatever' => {whatever => '', text => 'Your Mojo is working!'}); +} 1; @@ -25,6 +28,21 @@ L<Mojo::HelloWorld> is the default L<Mojolicious> application, used mostly for testing. +=head1 ATTRIBUTES + +L<Mojo::HelloWorld> inherits all attributes from L<Mojolicious>. + +=head1 METHODS + +L<Mojo::HelloWorld> inherits all methods from L<Mojolicious> and implements the +following new ones. + +=head2 startup + + $hello->startup; + +Creates a catch-all route that renders a text message. + =head1 SEE ALSO L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicious.org>. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/IOLoop/Server.pm new/Mojolicious-7.36/lib/Mojo/IOLoop/Server.pm --- old/Mojolicious-7.33/lib/Mojo/IOLoop/Server.pm 2017-02-27 17:40:51.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojo/IOLoop/Server.pm 2017-07-05 00:20:17.000000000 +0200 @@ -45,7 +45,7 @@ # Reuse file descriptor my $handle; my $class = $path ? 'IO::Socket::UNIX' : 'IO::Socket::IP'; - if (defined $fd) { + if (defined($fd //= $args->{fd})) { $handle = $class->new_from_fd($fd, 'r') or croak "Can't open file descriptor $fd: $!"; } @@ -223,6 +223,12 @@ Maximum backlog size, defaults to C<SOMAXCONN>. +=item fd + + fd => 3 + +File descriptor with an already prepared listen socket. + =item path path => '/tmp/myapp.sock' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/IOLoop/TLS.pm new/Mojolicious-7.36/lib/Mojo/IOLoop/TLS.pm --- old/Mojolicious-7.33/lib/Mojo/IOLoop/TLS.pm 2017-03-05 23:05:14.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojo/IOLoop/TLS.pm 2017-07-05 19:10:27.000000000 +0200 @@ -82,7 +82,7 @@ sub _tls { my ($self, $handle, $server) = @_; - return $self->emit(upgrade => delete $self->{handle}) + return $self->_cleanup->emit(upgrade => delete $self->{handle}) if $server ? $handle->accept_SSL : $handle->connect_SSL; # Switch between reading and writing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/Log.pm new/Mojolicious-7.36/lib/Mojo/Log.pm --- old/Mojolicious-7.33/lib/Mojo/Log.pm 2017-02-05 16:58:14.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojo/Log.pm 2017-07-09 19:04:10.000000000 +0200 @@ -6,7 +6,7 @@ use Mojo::File; use Mojo::Util 'encode'; -has format => sub { \&_format }; +has format => sub { shift->short ? \&_short : \&_default }; has handle => sub { # STDERR @@ -19,6 +19,8 @@ has level => 'debug'; has max_history_size => 10; has 'path'; +has short => + sub { $ENV{INVOCATION_ID} && $ENV{JOURNAL_STREAM} && !shift->path }; # Supported log levels my %LEVEL = (debug => 1, info => 2, warn => 3, error => 4, fatal => 5); @@ -47,7 +49,7 @@ sub warn { shift->_log(warn => @_) } -sub _format { +sub _default { '[' . localtime(shift) . '] [' . shift() . '] ' . join "\n", @_, ''; } @@ -66,6 +68,8 @@ $self->append($self->format->(@$msg)); } +sub _short { shift; '[' . shift() . '] ' . join "\n", @_, '' } + 1; =encoding utf8 @@ -168,6 +172,15 @@ Log file path used by L</"handle">. +=head2 short + + my $bool = $log->short; + $log = $log->short($bool); + +Generate short log messages without a timestamp, suitable for systemd, defaults +to auto-detection based on the presence of a L</"path"> and the +C<INVOCATION_ID> and C<JOURNAL_STREAM> environment variables. + =head1 METHODS L<Mojo::Log> inherits all methods from L<Mojo::EventEmitter> and implements the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/Message/Request.pm new/Mojolicious-7.36/lib/Mojo/Message/Request.pm --- old/Mojolicious-7.33/lib/Mojo/Message/Request.pm 2017-02-24 12:09:42.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojo/Message/Request.pm 2017-07-05 19:10:27.000000000 +0200 @@ -340,7 +340,8 @@ my $clone = $req->clone; -Clone request if possible, otherwise return C<undef>. +Return a new L<Mojo::Message::Request> object cloned from this request if +possible, otherwise return C<undef>. =head2 cookies diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/Message.pm new/Mojolicious-7.36/lib/Mojo/Message.pm --- old/Mojolicious-7.33/lib/Mojo/Message.pm 2017-01-29 22:33:08.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojo/Message.pm 2017-06-24 15:01:30.000000000 +0200 @@ -408,8 +408,7 @@ my $bytes = $msg->body; $msg = $msg->body('Hello!'); -Slurp or replace L</"content">, L<Mojo::Content::MultiPart> will be -automatically downgraded to L<Mojo::Content::Single>. +Slurp or replace L</"content">. =head2 body_params diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/Parameters.pm new/Mojolicious-7.36/lib/Mojo/Parameters.pm --- old/Mojolicious-7.33/lib/Mojo/Parameters.pm 2016-12-18 17:14:20.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojo/Parameters.pm 2017-07-05 19:10:27.000000000 +0200 @@ -247,7 +247,7 @@ my $params2 = $params->clone; -Clone parameters. +Return a new L<Mojo::Parameters> object cloned from these parameters. =head2 every_param diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/Path.pm new/Mojolicious-7.36/lib/Mojo/Path.pm --- old/Mojolicious-7.33/lib/Mojo/Path.pm 2016-12-18 17:14:50.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojo/Path.pm 2017-07-05 19:10:27.000000000 +0200 @@ -187,7 +187,7 @@ my $clone = $path->clone; -Clone path. +Return a new L<Mojo::Path> object cloned from this path. =head2 contains diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/Server/Daemon.pm new/Mojolicious-7.36/lib/Mojo/Server/Daemon.pm --- old/Mojolicious-7.33/lib/Mojo/Server/Daemon.pm 2017-02-22 16:20:31.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojo/Server/Daemon.pm 2017-07-05 00:19:42.000000000 +0200 @@ -171,12 +171,9 @@ croak qq{Invalid listen location "$listen"} unless $proto eq 'http' || $proto eq 'https' || $proto eq 'http+unix'; - my $query = $url->query; - my $options = { - backlog => $self->backlog, - single_accept => $query->param('single_accept'), - reuse => $query->param('reuse') - }; + my $query = $url->query; + my $options = {backlog => $self->backlog}; + $options->{$_} = $query->param($_) for qw(fd single_accept reuse); if ($proto eq 'http+unix') { $options->{path} = $url->host } else { if ((my $host = $url->host) ne '*') { $options->{address} = $host } @@ -370,6 +367,9 @@ # Listen on UNIX domain socket "/tmp/myapp.sock" (percent encoded slash) $daemon->listen(['http+unix://%2Ftmp%2Fmyapp.sock']); + # File descriptor, as used by systemd + $daemon->listen(['http://127.0.0.1?fd=3']); + # Allow multiple servers to use the same port (SO_REUSEPORT) $daemon->listen(['http://*:8080?reuse=1']); @@ -411,6 +411,12 @@ TLS cipher specification string. For more information about the format see L<https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-STRINGS>. +=item fd + + fd=3 + +File descriptor with an already prepared listen socket. + =item key key=/etc/tls/server.key diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/Server/Hypnotoad.pm new/Mojolicious-7.36/lib/Mojo/Server/Hypnotoad.pm --- old/Mojolicious-7.33/lib/Mojo/Server/Hypnotoad.pm 2017-03-05 23:04:56.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojo/Server/Hypnotoad.pm 2017-07-04 16:01:31.000000000 +0200 @@ -26,7 +26,7 @@ $prefork->max_requests($c->{requests}) if $c->{requests}; defined $c->{$_} and $prefork->$_($c->{$_}) for qw(accepts backlog graceful_timeout heartbeat_interval), - qw(heartbeat_timeout inactivity_timeout listen pid_file workers); + qw(heartbeat_timeout inactivity_timeout listen pid_file spare workers); } sub run { @@ -123,15 +123,15 @@ if ($self->{upgrade} && !$self->{finished}) { # Fresh start + my $ut = $self->upgrade_timeout; unless ($self->{new}) { - $log->info('Starting zero downtime software upgrade'); + $log->info("Starting zero downtime software upgrade ($ut seconds)"); die "Can't fork: $!" unless defined(my $pid = $self->{new} = fork); exec $^X, $ENV{HYPNOTOAD_EXE} or die "Can't exec: $!" unless $pid; } # Timeout - kill 'KILL', $self->{new} - if $self->{upgrade} + $self->upgrade_timeout <= steady_time; + kill 'KILL', $self->{new} if $self->{upgrade} + $ut <= steady_time; } } @@ -338,6 +338,15 @@ Number of keep-alive requests per connection, defaults to the value of L<Mojo::Server::Daemon/"max_requests">. +=head2 spare + + spare => 4 + +Temporarily spawn up to this number of additional workers if there is a need, +defaults to the value of L<Mojo::Server::Prefork/"spare">. This allows for new +workers to be started while old ones are still shutting down gracefully, +drastically reducing the performance cost of worker restarts. + =head2 upgrade_timeout upgrade_timeout => 45 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/Server/Morbo.pm new/Mojolicious-7.36/lib/Mojo/Server/Morbo.pm --- old/Mojolicious-7.33/lib/Mojo/Server/Morbo.pm 2017-04-04 17:02:14.000000000 +0200 +++ new/Mojolicious-7.36/lib/Mojo/Server/Morbo.pm 2017-07-03 09:33:58.000000000 +0200 @@ -6,7 +6,6 @@ # Morbo: Morbo is pleased but sticky." use Mojo::Loader 'load_class'; use Mojo::Server::Daemon; -use Mojo::Util 'deprecated'; use POSIX 'WNOHANG'; has backend => sub { @@ -36,13 +35,6 @@ exit 0; } -# DEPRECATED! -sub watch { - deprecated 'Mojo::Server::Morbo::watch is DEPRECATED' - . ' in favor of Mojo::Server::Morbo::Backend::Poll::watch'; - shift->backend->watch(@_); -} - sub _manage { my $self = shift; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/Server/Prefork.pm new/Mojolicious-7.36/lib/Mojo/Server/Prefork.pm --- old/Mojolicious-7.33/lib/Mojo/Server/Prefork.pm 2017-02-22 14:59:44.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojo/Server/Prefork.pm 2017-07-04 17:22:24.000000000 +0200 @@ -8,11 +8,13 @@ use POSIX 'WNOHANG'; use Scalar::Util 'weaken'; -has accepts => 10000; -has cleanup => 1; -has [qw(graceful_timeout heartbeat_timeout)] => 20; +has accepts => 10000; +has cleanup => 1; +has graceful_timeout => 60; +has heartbeat_timeout => 30; has heartbeat_interval => 5; has pid_file => sub { path(tmpdir, 'prefork.pid')->to_string }; +has spare => 2; has workers => 4; sub DESTROY { unlink $_[0]->pid_file if $_[0]->cleanup } @@ -91,7 +93,11 @@ # Spawn more workers if necessary and check PID file if (!$self->{finished}) { - $self->_spawn while keys %{$self->{pool}} < $self->workers; + my $graceful = grep { $_->{graceful} } values %{$self->{pool}}; + my $spare = $self->spare; + $spare = $graceful ? $graceful > $spare ? $spare : $graceful : 0; + my $need = ($self->workers - keys %{$self->{pool}}) + $spare; + $self->_spawn while $need-- > 0; $self->ensure_pid_file($$); } @@ -111,19 +117,19 @@ next unless my $w = $self->{pool}{$pid}; # No heartbeat (graceful stop) - $log->error("Worker $pid has no heartbeat, restarting") + $log->error("Worker $pid has no heartbeat ($ht seconds), restarting") and $w->{graceful} = $time if !$w->{graceful} && ($w->{time} + $interval + $ht <= $time); # Graceful stop with timeout my $graceful = $w->{graceful} ||= $self->{graceful} ? $time : undef; - $log->debug("Stopping worker $pid gracefully") + $log->info("Stopping worker $pid gracefully ($gt seconds)") and (kill 'QUIT', $pid or $self->_stopped($pid)) if $graceful && !$w->{quit}++; $w->{force} = 1 if $graceful && $graceful + $gt <= $time; # Normal stop - $log->debug("Stopping worker $pid") + $log->warn("Stopping worker $pid immediately") and (kill 'KILL', $pid or $self->_stopped($pid)) if $w->{force} || ($self->{finished} && !$graceful); } @@ -153,7 +159,7 @@ delete $self->{reader}; srand; - $self->app->log->debug("Worker $$ started"); + $self->app->log->info("Worker $$ started"); $loop->start; exit 0; } @@ -164,7 +170,7 @@ return unless my $w = delete $self->{pool}{$pid}; my $log = $self->app->log; - $log->debug("Worker $pid stopped"); + $log->info("Worker $pid stopped"); $log->error("Worker $pid stopped too early, shutting down") and $self->_term unless $w->{healthy}; } @@ -376,7 +382,7 @@ $prefork = $prefork->graceful_timeout(15); Maximum amount of time in seconds stopping a worker gracefully may take before -being forced, defaults to C<20>. Note that this value should usually be a little +being forced, defaults to C<60>. Note that this value should usually be a little larger than the maximum amount of time you expect any one request to take. =head2 heartbeat_interval @@ -392,7 +398,7 @@ $prefork = $prefork->heartbeat_timeout(2); Maximum amount of time in seconds before a worker without a heartbeat will be -stopped gracefully, defaults to C<20>. Note that this value should usually be a +stopped gracefully, defaults to C<30>. Note that this value should usually be a little larger than the maximum amount of time you expect any one operation to block the event loop. @@ -404,6 +410,16 @@ Full path of process id file, defaults to C<prefork.pid> in a temporary directory. +=head2 spare + + my $spare = $prefork->spare; + $prefork = $prefork->spare(4); + +Temporarily spawn up to this number of additional workers if there is a need, +defaults to C<2>. This allows for new workers to be started while old ones are +still shutting down gracefully, drastically reducing the performance cost of +worker restarts. + =head2 workers my $workers = $prefork->workers; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/URL.pm new/Mojolicious-7.36/lib/Mojo/URL.pm --- old/Mojolicious-7.33/lib/Mojo/URL.pm 2017-02-24 11:55:45.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojo/URL.pm 2017-07-05 19:10:27.000000000 +0200 @@ -294,7 +294,7 @@ my $url2 = $url->clone; -Clone this URL. +Return a new L<Mojo::URL> object cloned from this URL. =head2 host_port @@ -457,8 +457,8 @@ my $abs = $url->to_abs; my $abs = $url->to_abs(Mojo::URL->new('http://example.com/foo')); -Clone relative URL and turn it into an absolute one using L</"base"> or -provided base URL. +Return a new L<Mojo::URL> object cloned from this relative URL and turn it into +an absolute one using L</"base"> or provided base URL. # "http://example.com/foo/baz.xml?test=123" Mojo::URL->new('baz.xml?test=123') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojo/WebSocket.pm new/Mojolicious-7.36/lib/Mojo/WebSocket.pm --- old/Mojolicious-7.33/lib/Mojo/WebSocket.pm 2016-07-19 02:38:18.000000000 +0200 +++ new/Mojolicious-7.36/lib/Mojo/WebSocket.pm 2017-06-24 15:01:30.000000000 +0200 @@ -101,7 +101,7 @@ # Head return undef unless length $$buffer >= 2; - my ($first, $second) = unpack 'C*', substr($$buffer, 0, 2); + my ($first, $second) = unpack 'C2', $$buffer; # FIN my $fin = ($first & 0b10000000) == 0b10000000 ? 1 : 0; @@ -123,7 +123,7 @@ elsif ($len == 126) { return undef unless length $$buffer > 4; $hlen = 4; - $len = unpack 'n', substr($$buffer, 2, 2); + $len = unpack 'x2n', $$buffer; warn "-- Extended 16-bit payload ($len)\n" if DEBUG; } @@ -131,8 +131,7 @@ elsif ($len == 127) { return undef unless length $$buffer > 10; $hlen = 10; - my $ext = substr $$buffer, 2, 8; - $len = MODERN ? unpack('Q>', $ext) : unpack('N', substr($ext, 4, 4)); + $len = MODERN ? unpack('x2Q>', $$buffer) : unpack('x2x4N', $$buffer); warn "-- Extended 64-bit payload ($len)\n" if DEBUG; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojolicious/Command/prefork.pm new/Mojolicious-7.36/lib/Mojolicious/Command/prefork.pm --- old/Mojolicious-7.33/lib/Mojolicious/Command/prefork.pm 2017-02-24 14:37:47.000000000 +0100 +++ new/Mojolicious-7.36/lib/Mojolicious/Command/prefork.pm 2017-07-08 23:00:17.000000000 +0200 @@ -24,6 +24,7 @@ 'P|pid-file=s' => sub { $prefork->pid_file($_[1]) }, 'p|proxy' => sub { $prefork->reverse_proxy(1) }, 'r|requests=i' => sub { $prefork->max_requests($_[1]) }, + 's|spare=i' => sub { $prefork->spare($_[1]) }, 'w|workers=i' => sub { $prefork->workers($_[1]) }; $prefork->listen(\@listen) if @listen; @@ -46,7 +47,7 @@ ./myapp.pl prefork -m production -l http://*:8080 ./myapp.pl prefork -l http://127.0.0.1:8080 -l https://[::]:8081 ./myapp.pl prefork -l 'https://*:443?cert=./server.crt&key=./server.key' - ./myapp.pl prefork -l http+unix://%2Ftmp%2Fmyapp.sock + ./myapp.pl prefork -l http+unix://%2Ftmp%2Fmyapp.sock -w 12 Options: -a, --accepts <number> Number of connections for workers to @@ -55,9 +56,9 @@ SOMAXCONN -c, --clients <number> Maximum number of concurrent connections, defaults to 1000 - -G, --graceful-timeout <seconds> Graceful timeout, defaults to 20. + -G, --graceful-timeout <seconds> Graceful timeout, defaults to 60. -I, --heartbeat-interval <seconds> Heartbeat interval, defaults to 5 - -H, --heartbeat-timeout <seconds> Heartbeat timeout, defaults to 20 + -H, --heartbeat-timeout <seconds> Heartbeat timeout, defaults to 30 -h, --help Show this summary of available options --home <path> Path to home directory of your application, defaults to the value of @@ -71,12 +72,14 @@ defaults to the value of MOJO_MODE/PLACK_ENV or "development" -P, --pid-file <path> Path to process id file, defaults to - "prefork.pid" in a temporary diretory + "prefork.pid" in a temporary directory -p, --proxy Activate reverse proxy support, defaults to the value of MOJO_REVERSE_PROXY -r, --requests <number> Maximum number of requests per keep-alive connection, defaults to 100 + -s, --spare <number> Temporarily spawn up to this number of + additional workers, defaults to 2 -w, --workers <number> Number of workers, defaults to 4 =head1 DESCRIPTION diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojolicious/Guides/FAQ.pod new/Mojolicious-7.36/lib/Mojolicious/Guides/FAQ.pod --- old/Mojolicious-7.33/lib/Mojolicious/Guides/FAQ.pod 2017-06-01 02:25:07.000000000 +0200 +++ new/Mojolicious-7.36/lib/Mojolicious/Guides/FAQ.pod 2017-07-04 17:22:00.000000000 +0200 @@ -203,14 +203,14 @@ response or that the user agent got destroyed, which forces all connections to be closed immediately. -=head2 What does "Worker 31842 has no heartbeat, restarting" mean? +=head2 What does "Worker 31842 has no heartbeat (30 seconds), restarting" mean? As long as they are accepting new connections, worker processes of all built-in pre-forking web servers send heartbeat messages to the manager process at regular intervals, to signal that they are still responsive. A blocking operation such as an infinite loop in your application can prevent this, and will force the affected worker to be restarted after a timeout. This timeout -defaults to C<20> seconds and can be extended with the attribute +defaults to C<30> seconds and can be extended with the attribute L<Mojo::Server::Prefork/"heartbeat_timeout"> if your application requires it. =head2 What does "Connection already closed" mean? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojolicious/Guides/Rendering.pod new/Mojolicious-7.36/lib/Mojolicious/Guides/Rendering.pod --- old/Mojolicious-7.33/lib/Mojolicious/Guides/Rendering.pod 2017-05-06 16:25:50.000000000 +0200 +++ new/Mojolicious-7.36/lib/Mojolicious/Guides/Rendering.pod 2017-06-24 15:01:30.000000000 +0200 @@ -1061,6 +1061,7 @@ C<If-Modified-Since> and C<If-None-Match> headers. use Mojolicious::Lite; + use Mojo::Asset::File; get '/leak' => sub { my $c = shift; @@ -1075,6 +1076,7 @@ generating a response. use Mojolicious::Lite; + use Mojo::Asset::File; get '/leak' => sub { my $c = shift; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojolicious/Guides.pod new/Mojolicious-7.36/lib/Mojolicious/Guides.pod --- old/Mojolicious-7.33/lib/Mojolicious/Guides.pod 2017-06-04 14:07:23.000000000 +0200 +++ new/Mojolicious-7.36/lib/Mojolicious/Guides.pod 2017-07-08 13:16:12.000000000 +0200 @@ -216,13 +216,9 @@ =over 2 -=item * L<Mojolicious::Lite> - -=over 2 - =item * L<Mojo::HelloWorld> -=back +=item * L<Mojolicious::Lite> =back diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/lib/Mojolicious.pm new/Mojolicious-7.36/lib/Mojolicious.pm --- old/Mojolicious-7.33/lib/Mojolicious.pm 2017-05-30 19:08:06.000000000 +0200 +++ new/Mojolicious-7.36/lib/Mojolicious.pm 2017-07-05 19:10:27.000000000 +0200 @@ -58,7 +58,7 @@ has validator => sub { Mojolicious::Validator->new }; our $CODENAME = 'Doughnut'; -our $VERSION = '7.33'; +our $VERSION = '7.36'; sub AUTOLOAD { my $self = shift; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/t/mojo/daemon.t new/Mojolicious-7.36/t/mojo/daemon.t --- old/Mojolicious-7.33/t/mojo/daemon.t 2017-01-25 18:52:02.000000000 +0100 +++ new/Mojolicious-7.36/t/mojo/daemon.t 2017-07-08 13:15:13.000000000 +0200 @@ -7,6 +7,7 @@ use Test::More; use FindBin; +use IO::Socket::INET; use Mojo; use Mojo::File 'path'; use Mojo::IOLoop; @@ -120,31 +121,38 @@ $app->routes->post( '/chunked' => sub { - my $self = shift; + my $c = shift; - my $params = $self->req->params->to_hash; + my $params = $c->req->params->to_hash; my @chunks; for my $key (sort keys %$params) { push @chunks, $params->{$key} } my $cb; $cb = sub { - my $self = shift; + my $c = shift; $cb = undef unless my $chunk = shift @chunks || ''; - $self->write_chunk($chunk, $cb); + $c->write_chunk($chunk, $cb); }; - $self->$cb; + $c->$cb; } ); my ($local_address, $local_port, $remote_address, $remote_port); $app->routes->post( '/upload' => sub { - my $self = shift; - $local_address = $self->tx->local_address; - $local_port = $self->tx->local_port; - $remote_address = $self->tx->remote_address; - $remote_port = $self->tx->remote_port; - $self->render(data => $self->req->upload('file')->slurp); + my $c = shift; + $local_address = $c->tx->local_address; + $local_port = $c->tx->local_port; + $remote_address = $c->tx->remote_address; + $remote_port = $c->tx->remote_port; + $c->render(data => $c->req->upload('file')->slurp); + } +); + +$app->routes->any( + '/port' => sub { + my $c = shift; + $c->render(text => $c->req->url->to_abs->port); } ); @@ -237,7 +245,7 @@ $daemon = Mojo::Server::Daemon->new({listen => ['http://127.0.0.1'], silent => 1}); my $port = $daemon->start->ports->[0]; -is $daemon->app->moniker, 'HelloWorld', 'right moniker'; +is $daemon->app->moniker, 'mojo-hello_world', 'right moniker'; my $buffer = ''; my $id; $id = Mojo::IOLoop->client( @@ -325,6 +333,20 @@ is $tx->res->code, 200, 'right status'; is $tx->res->body, 'Whatever!', 'right content'; +# File descriptor +my $listen = IO::Socket::INET->new(Listen => 5, LocalAddr => '127.0.0.1'); +my $fd = fileno $listen; +$daemon = Mojo::Server::Daemon->new( + app => $app, + listen => ["http://127.0.0.1?fd=$fd"], + silent => 1 +)->start; +$port = $listen->sockport; +is $daemon->ports->[0], $port, 'same port'; +$tx = $ua->get("http://127.0.0.1:$port/port"); +is $tx->res->code, 200, 'right status'; +is $tx->res->body, $port, 'right content'; + # No TLS support eval { Mojo::Server::Daemon->new(listen => ['https://127.0.0.1'], silent => 1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/t/mojo/file.t new/Mojolicious-7.36/t/mojo/file.t --- old/Mojolicious-7.33/t/mojo/file.t 2017-04-04 16:39:37.000000000 +0200 +++ new/Mojolicious-7.36/t/mojo/file.t 2017-07-07 10:46:57.000000000 +0200 @@ -48,6 +48,7 @@ is path('file.t')->to_abs->basename, basename(rel2abs 'file.t'), 'same path'; is path('file.t')->to_abs->basename('.t'), basename(rel2abs('file.t'), '.t'), 'same path'; +is path('file.t')->basename('.t'), basename('file.t', '.t'), 'same path'; # Dirname is path('file.t')->to_abs->dirname, scalar dirname(rel2abs 'file.t'), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/t/mojo/hypnotoad.t new/Mojolicious-7.36/t/mojo/hypnotoad.t --- old/Mojolicious-7.33/t/mojo/hypnotoad.t 2017-01-09 18:47:43.000000000 +0100 +++ new/Mojolicious-7.36/t/mojo/hypnotoad.t 2017-07-04 16:00:54.000000000 +0200 @@ -29,6 +29,7 @@ pid_file => '/foo/bar.pid', proxy => 1, requests => 3, + spare => 4, upgrade_timeout => 45, workers => 7 }; @@ -47,7 +48,8 @@ is $hypnotoad->prefork->max_requests, 3, 'right value'; is $hypnotoad->prefork->pid_file, '/foo/bar.pid', 'right value'; ok $hypnotoad->prefork->reverse_proxy, 'reverse proxy enabled'; - is $hypnotoad->prefork->workers, 7, 'right value'; + is $hypnotoad->prefork->spare, 4, 'right value'; + is $hypnotoad->prefork->workers, 7, 'right value'; is $hypnotoad->upgrade_timeout, 45, 'right value'; } @@ -250,9 +252,10 @@ # Check log $log = $log->slurp; -like $log, qr/Worker \d+ started/, 'right message'; -like $log, qr/Starting zero downtime software upgrade/, 'right message'; -like $log, qr/Upgrade successful, stopping $old/, 'right message'; +like $log, qr/Worker \d+ started/, 'right message'; +like $log, qr/Starting zero downtime software upgrade \(60 seconds\)/, + 'right message'; +like $log, qr/Upgrade successful, stopping $old/, 'right message'; sub _pid { return undef unless open my $file, '<', $dir->child('hypnotoad.pid'); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/t/mojo/log.t new/Mojolicious-7.36/t/mojo/log.t --- old/Mojolicious-7.33/t/mojo/log.t 2017-01-09 18:47:43.000000000 +0100 +++ new/Mojolicious-7.36/t/mojo/log.t 2017-07-09 19:02:42.000000000 +0200 @@ -50,6 +50,24 @@ like $log->format->(time, 'debug', qw(Test 1 2 3)), qr/^debug:\d+:Test:1:2:3$/, 'right format'; +# systemd +{ + $log = Mojo::Log->new; + ok !$log->short, 'systemd has not been detected'; + like $log->format->(time, 'debug', 'Test 123'), + qr/^\[.*\] \[debug\] Test 123\n$/, 'right format'; + local $ENV{JOURNAL_STREAM} = '1:23456'; + local $ENV{INVOCATION_ID} = 1; + $log = Mojo::Log->new; + ok $log->short, 'systemd has been detected'; + like $log->format->(time, 'debug', 'Test 123'), qr/^\[debug\] Test 123\n$/, + 'right format'; + $log = Mojo::Log->new(path => $path); + ok !$log->short, 'a path will be used'; + like $log->format->(time, 'debug', 'Test 123'), + qr/^\[.*\] \[debug\] Test 123\n$/, 'right format'; +} + # Events $log = Mojo::Log->new; my $msgs = []; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-7.33/t/mojo/prefork.t new/Mojolicious-7.36/t/mojo/prefork.t --- old/Mojolicious-7.33/t/mojo/prefork.t 2017-03-05 23:08:00.000000000 +0100 +++ new/Mojolicious-7.36/t/mojo/prefork.t 2017-07-04 11:51:29.000000000 +0200 @@ -79,12 +79,13 @@ is_deeply [sort @spawn], [sort @reap], 'same process ids'; is $tx->res->code, 200, 'right status'; is $tx->res->body, 'just works!', 'right content'; -like $log, qr/Listening at/, 'right message'; -like $log, qr/Manager $$ started/, 'right message'; -like $log, qr/Creating process id file/, 'right message'; -like $log, qr/Stopping worker $spawn[0] gracefully/, 'right message'; -like $log, qr/Worker $spawn[0] stopped/, 'right message'; -like $log, qr/Manager $$ stopped/, 'right message'; +like $log, qr/Listening at/, 'right message'; +like $log, qr/Manager $$ started/, 'right message'; +like $log, qr/Creating process id file/, 'right message'; +like $log, qr/Stopping worker $spawn[0] gracefully \(60 seconds\)/, + 'right message'; +like $log, qr/Worker $spawn[0] stopped/, 'right message'; +like $log, qr/Manager $$ stopped/, 'right message'; $prefork->app->log->unsubscribe(message => $cb); # Process id file
