Skip Menu |

This queue is for tickets about the Gearman-Server CPAN distribution.

Report information
The Basics
Id: 115368
Status: resolved
Priority: 0/
Queue: Gearman-Server

People
Owner: Nobody in particular
Requestors: PLICEASE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Feature Request: Allow bind to specific IP address
It would be nice to be able to bind to a specific IP address, rather than all of them. Providing a patch which implements this proposal.
Subject: specific-ip.patch
commit a140d615ae5b545256c93eb7e0556cbe550c73b2 Author: Graham Ollis <plicease@cpan.org> Date: Thu Jun 16 10:30:48 2016 -0400 Add option to bind to a specific IP diff --git a/gearmand b/gearmand index 106c6bf..f3cc1ac 100755 --- a/gearmand +++ b/gearmand @@ -27,6 +27,10 @@ for running under daemontools/supervise). Set the port number, defaults to 7003. +=item --host hostname / -h hostname + +Bind to the given hostname or IP address. + =item --pidfile=/some/dir/gearmand.pid Write a pidfile when starting up @@ -121,11 +125,13 @@ my ( $accept, $wakeup, $wakeup_delay, + $conf_host, ); my $conf_port = 7003; Getopt::Long::GetOptions( 'd|daemonize' => \$daemonize, + 'h|host=s' => \$conf_host, 'p|port=i' => \$conf_port, 'debug=i' => \$DEBUG, 'pidfile=s' => \$opt_pidfile, @@ -147,7 +153,7 @@ my $server = Gearman::Server->new( wakeup => $wakeup, wakeup_delay => $wakeup_delay, ); -my $ssock = $server->create_listening_sock($conf_port, accept_per_loop => $accept); +my $ssock = $server->create_listening_sock($conf_port, accept_per_loop => $accept, local_addr => $conf_host); if ($opt_pidfile) { open my $fh, '>', $opt_pidfile or die "Could not open $opt_pidfile: $!"; diff --git a/lib/Gearman/Server.pm b/lib/Gearman/Server.pm index 9f64c65..d2e6b64 100644 --- a/lib/Gearman/Server.pm +++ b/lib/Gearman/Server.pm @@ -120,9 +120,19 @@ sub debug { =head2 create_listening_sock - $server_object->create_listening_sock( $portnum ) + $server_object->create_listening_sock( $portnum, \%options ) -Add a TCP port listener for incoming Gearman worker and client connections. +Add a TCP port listener for incoming Gearman worker and client connections. Options: + +=over 4 + +=item accept_per_loop + +=item local_addr + +Bind socket to only this address. + +=back =cut @@ -130,6 +140,7 @@ sub create_listening_sock { my ($self, $portnum, %opts) = @_; my $accept_per_loop = delete $opts{accept_per_loop}; + my $local_addr = delete $opts{local_addr}; warn "Extra options passed into create_listening_sock: " . join(', ', keys %opts) . "\n" if keys %opts; @@ -139,7 +150,8 @@ sub create_listening_sock { Proto => IPPROTO_TCP, Blocking => 0, Reuse => 1, - Listen => 1024 ) + Listen => 1024, + ($local_addr ? (LocalAddr => $local_addr) : ()) ) or die "Error creating socket: $@\n"; my $listeners = $self->{listeners};
it'll be done in upcoming v1.13.001
it'll be done in upcoming v1.13.001
done in v1.130.0
On Tue Jul 12 03:51:31 2016, palik wrote: Show quoted text
> done in v1.130.0
Thanks for addressing these issues! Is the source repository for this dist publicly accessible somewhere?
Subject: Re: [rt.cpan.org #115368] Feature Request: Allow bind to specific IP address
Date: Tue, 12 Jul 2016 13:18:17 +0200 (CEST)
To: bug-Gearman-Server [...] rt.cpan.org
From: Alexei Pastuchov <info [...] maximka.de>
Show quoted text
> Thanks for addressing these issues! Is the source repository for this dist > publicly accessible somewhere?
Yes indeed, https://github.com/p-alik/Gearman-Server It'll be added to Gearman::Server pod soon.