Giter Club home page Giter Club logo

Comments (12)

miyagawa avatar miyagawa commented on July 17, 2024

I can't reproduce:

➜  ~  starman --backlog 600 --listen 0.0.0.0:8080 dev/Plack/eg/dot-psgi/Hello.psgi
2012/12/11-13:55:54 Starman::Server (type Net::Server::PreFork) starting! pid(25819)
Binding to TCP port 8080 on host 0.0.0.0 with IPv4
Setting gid to "20 20 20 401 12 33 61 79 80 81 98 100 204 402"

Check the versions of Plack, Starman and Net::Server and ugprade to the latest to see if the problem exists.

If it is fixed by upgrading versions, report it to me so that we can fix the dependency if there's any mistake.

from starman.

Perlover avatar Perlover commented on July 17, 2024

Thanks!

I made same tests and result exactly as your one
But if i run a project there i see error again (same machine and modules)
I noticed in code a following:

starman runs Plack::Runner and uses parse_options() for parsing of @argv

Plack::Runner::parse_options parses an options but parsed options are not deleted from hash and kept in $self->{argv}

Starman::Server::run kept options in @argv again before Net::Server::PreFork::run:
local @argv = (@{$options->{argv} || []});

And after runs the $self->SUPER::run (Net::Server::PreFork::run)

I think the 'listen' option is passed to Net::Server::PreFork again through @argv and affects there in some situations.
This option means a backlog queue of socket for Net::Server::* and means IP:PORT for Plack/starman
Same name but different values

I don't understand why i cannot reproduce with your example (application Plack/eg/dot-psgi/Hello.psgi) but i see errors there with same Plack/Starman/Net::Server modules for my project.

from starman.

Perlover avatar Perlover commented on July 17, 2024

I made:

vi /usr/local/lib/perl5/site_perl/5.16.2/Starman/Server.pm

Added code:

{
use Data::Dumper;
open FILE, '>', '/tmp/dump.txt';
print FILE Dumper( [ ARGV => \@ARGV, options => $options ] );
close FILE;
}

before $self->SUPER::run and got:

$ less /tmp/dump.txt

$VAR1 = [
          'ARGV',
          [
            '--listen',
            'MY_IP_ADDRESS:MY_PORT',
            '--min_servers=12',
            '--max_servers=48',
            '--min_spare_servers=4',
            '--max_spare_servers=20',
            '--backlog',
            '6000',
            '--pid',
            '/home/my_app/my_app/run/services/starman.pid',
            '--error-log',
            '/home/my_app/my_app/logs/starman/error.log',
            '--access-log',
            '/home/my_app/my_app/logs/starman/access.log',
            '--daemonize',
            '--app',
            '/home/my_app/perl5/bin/my_app.psgi'
          ],
          'options',
          {
            'backlog' => '6000',
            'error_log' => '/home/my_app/my_app/logs/starman/error.log',
            'keepalive_timeout' => 1,
            'min_servers' => '12',
            'port' => 'MY_PORT',
            'host' => 'MY_IP_ADDRESS',
            'socket' => undef,
            'max_servers' => '48',
            'listen' => [
                          'MY_IP_ADDRESS:MY_PORT'
                        ],
            'pid' => '/home/my_app/my_app/run/services/starman.pid',
            'argv' => [
                        '--listen',
                        'MY_IP_ADDRESS:MY_PORT',
                        '--min_servers=12',
                        '--max_servers=48',
                        '--min_spare_servers=4',
                        '--max_spare_servers=20',
                        '--backlog',
                        '6000',
                        '--pid',
                        '/home/my_app/my_app/run/services/starman.pid',
                        '--error-log',
                        '/home/my_app/my_app/logs/starman/error.log',
                        '--access-log',
                        '/home/my_app/my_app/logs/starman/access.log',
                        '--daemonize',
                        '--app',
                        '/home/my_app/perl5/bin/my_app.psgi'
                      ],
            'keepalive' => 1,
            'min_spare_servers' => '4',
            'daemonize' => 1,
            'max_spare_servers' => '20'
          }
        ];

from starman.

Perlover avatar Perlover commented on July 17, 2024

So Net::Server in @argv has --listen as IP:PORT but he expects there length of queue (backlog)
So there is bug

from starman.

miyagawa avatar miyagawa commented on July 17, 2024

and how can you reproduce? Can you make a reproducible script that doesn't
depend on your application?

from starman.

Perlover avatar Perlover commented on July 17, 2024

Net::Server:

sub configure {
my $self = shift;
my $prop = $self->{'server'};
my $template = ($_[0] && ref($_[0])) ? shift : undef;

$self->process_args(\@ARGV, $template) if @ARGV; # command line
$self->process_args($prop->{'_run_args'}, $template) if $prop->{'_run_args'}; # passed to run

if ($prop->{'conf_file'}) {
    $self->process_args($self->_read_conf($prop->{'conf_file'}), $template);
} else {
    my $def = $self->default_values || {};
    $self->process_args($self->_read_conf($def->{'conf_file'}), $template) if $def->{'conf_file'};
}
}

from starman.

Perlover avatar Perlover commented on July 17, 2024
 and how can you reproduce? Can you make a reproducible script that doesn't depend on your application?

I will try it through 2-3 hours

from starman.

Perlover avatar Perlover commented on July 17, 2024

I am trying to reproduce with Plack/eg/dot-psgi/Hello.psgi but i cannot while
But anyway it's bad idea to pass --listen option through @argv when in Plack this means IP[:PORT] but in Net::Server it means backlog queue.

Comment from Net::Server:process_args:

we want subsequent calls to not overwrite or add to previously set values so that command line arguments win

I think better way to remove --listen from @argv before Net::Server::PreFork::run method execution

from starman.

miyagawa avatar miyagawa commented on July 17, 2024

But anyway it's bad idea to pass --listen option through @argv when in Plack this means IP[:PORT] but in Net::Server it means backlog queue.

Sure, that's why we clear stuff out of @ARGV in Plack::Runner and when evaluating .psgi script etc. but maybe we should do that more aggressively? I can't confirm until you come up with a standalone debug script, because it doesn't occur in my instance.

from starman.

Perlover avatar Perlover commented on July 17, 2024
     Sure, that's why we clear stuff out of @ARGV in Plack::Runner and when evaluating .psgi script etc. but maybe we should do that more aggressively?

Yes, may be Plack cleans @argv but Starman restores @argv before Net::Server::run execution

I am seeing the code of Net::Server now because i want to understand how to reproduce problem with --listen

from starman.

miyagawa avatar miyagawa commented on July 17, 2024

Yes, may be Plack cleans @argv but Starman restores @argv before Net::Server::run execution

Right, but that @ARGV is restored from $options->{argv} which is already filtered out from Plack::Runner. plackup common options such as --listen are meant to be filtered out.

...

Ok, now that I tried to confirm the behavior and found that $options->{argv} is being recreated from the original script's ARGV, mainly to support HUP based restart which is not supported right now. See 6abaa02

I will remove this and argv will not propagated to Net::Server.

from starman.

Perlover avatar Perlover commented on July 17, 2024

Yes, i confirm that i don't have any warnings from IO::Socket now :)
I installed new version from master branch and now all is OK :)
Thanks!

from starman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.