Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update outdated code #1

Open
wants to merge 95 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
5a95cbf
import v1.12
Jul 2, 2016
c0a1fc1
Gearman::Server::Job requires Gearman::Server::Client
p-alik Jul 9, 2016
885feb3
perltidy Server
p-alik Jul 9, 2016
d3d4440
perltidy Client
p-alik Jul 9, 2016
ca29fc6
perltidy Listener
p-alik Jul 9, 2016
f46e8f2
server uses warnings
p-alik Jul 9, 2016
b730944
client uses warnings
p-alik Jul 9, 2016
aeb2b5f
listener uses warnings
p-alik Jul 9, 2016
e49089d
gearmand moved into bin
p-alik Jul 9, 2016
07b71b0
git mv gearmand bin/
p-alik Jul 9, 2016
bc260ec
job uses warnings
p-alik Jul 9, 2016
f2b0a3b
replace default port by 4730
p-alik Jul 9, 2016
187d7da
gearmand tidied
p-alik Jul 9, 2016
ed0ab48
gearmand env perl to be bsd conform
p-alik Jul 9, 2016
cc05a39
gearmand comments moved from the end of statement to previous line
p-alik Jul 9, 2016
59a1e50
server v1.13.001
p-alik Jul 9, 2016
f176fd0
reorderd moduls in server
p-alik Jul 9, 2016
7f999c6
split long comment
p-alik Jul 9, 2016
4774a3e
client v1.13.001
p-alik Jul 9, 2016
4568eb4
job v1.13.001
p-alik Jul 9, 2016
fdbb9d3
listener v1.13.001
p-alik Jul 9, 2016
de923f2
add use test
p-alik Jul 9, 2016
fb7ec6b
update MANIFEST
p-alik Jul 9, 2016
98db0cf
gearmand supports version option
p-alik Jul 10, 2016
f596b71
Bug #89033 for Gearman-Server: typo fixes
Jul 11, 2016
33ad356
Bug #107045 for Gearman-Server: [PATCH] fix pod whatis
Jul 11, 2016
7a62144
trim
Jul 11, 2016
2b18b30
Bug #115368 for Gearman-Server: Feature Request: Allow bind to specif…
Jul 11, 2016
578b2ce
pod usage
Jul 11, 2016
bc87f7d
changes update
Jul 11, 2016
b4330ac
obsolete
Jul 11, 2016
9e01641
cleanup MANIFEST
Jul 11, 2016
fc08fd0
travis ci
Jul 11, 2016
f3be8e1
add README
Jul 11, 2016
840f9a8
add README
Jul 11, 2016
cf4bad1
typo
Jul 11, 2016
4f34bce
rm matrix; cover test
Jul 11, 2016
47531c6
make
p-alik Jul 11, 2016
4309065
prereq version
p-alik Jul 11, 2016
20277b0
up to v1.130.0
p-alik Jul 11, 2016
d1862c7
build req Test::Script
p-alik Jul 11, 2016
7222f6f
rm FindBin
p-alik Jul 11, 2016
1b139df
+script_compiles_ok
p-alik Jul 11, 2016
943fd5c
repair gearmand link
p-alik Jul 12, 2016
6e36af1
update version to 1.130.1
p-alik Jul 12, 2016
d5eb82e
an other gearmand link repaired
p-alik Jul 12, 2016
3048df2
update changes
p-alik Jul 12, 2016
73d10f5
add dist meta to point ot repository
plicease Jul 12, 2016
9489175
Revert "an other gearmand link repaired"
p-alik Jul 12, 2016
4aed146
Revert "repair gearmand link"
p-alik Jul 12, 2016
9a49b8d
v 1.130.2
p-alik Jul 12, 2016
2121602
use Gearman::Util
p-alik Jul 12, 2016
a3a90fd
use Gearman::Util && IO::Socket::INET
p-alik Jul 12, 2016
94cd974
rm Gearman::Util && IO::Socket::INET
p-alik Jul 12, 2016
622271d
initial gearman server test script
p-alik Jul 12, 2016
8f0389e
gearman server can test
p-alik Jul 13, 2016
b64106a
gearmand options defined in GetOptions
p-alik Jul 13, 2016
e838129
create_listening_sock subtest
p-alik Jul 13, 2016
dce6f82
gearman server cliet test script
p-alik Jul 13, 2016
1f62605
server.pm new refactoring
p-alik Aug 5, 2016
90d2b22
Gearman::Server subtest new
p-alik Aug 5, 2016
e4503ca
build requires Test::Exception, Sys::Hostname
p-alik Aug 5, 2016
6f65245
Gearman::Server pod
p-alik Aug 7, 2016
ac4ade0
Gearmand::Server::Client pod
p-alik Aug 7, 2016
0c6aa6d
Gearman::Server::Job pod
p-alik Aug 7, 2016
4ca34bc
Gearman::Server::Listener pod
p-alik Aug 7, 2016
079331a
default
p-alik Aug 7, 2016
5054f70
Gearman::Server more pod
p-alik Aug 9, 2016
3a521ea
rename variables
p-alik Aug 9, 2016
cbd83b7
pod agian
p-alik Aug 9, 2016
7264ee5
client pod
p-alik Aug 9, 2016
c0fa567
server pod
p-alik Aug 9, 2016
294a81e
listener pod
p-alik Aug 9, 2016
8fa34a4
bug fixing: set max queue - delete if 0
p-alik Aug 9, 2016
d4db359
build requirements
p-alik Aug 9, 2016
357eeeb
server subtests: maxqueue and clients
p-alik Aug 9, 2016
d29aa8e
Test::Gearman::Server
p-alik Aug 10, 2016
1a33fea
free_port sub moved into Test::Gearman::Server
p-alik Aug 10, 2016
07286e8
no need for SOL_SOCKET, AF_UNIX ..
p-alik Aug 10, 2016
8d33f4e
client new subtest
p-alik Aug 10, 2016
0a91935
client can tests
p-alik Aug 10, 2016
0132b7a
catch open/close errors
p-alik Aug 11, 2016
d6f9b25
new maxqueue test script [ci skip]
p-alik Aug 17, 2016
14d88c7
add build requirements
p-alik Aug 17, 2016
5d28a20
no more support for "shutdown" and "shutdown graceful" commands
p-alik Feb 7, 2017
9692f1a
bug fixing Gearman::Server::Client::err_line unknown_command
p-alik Feb 7, 2017
3a4d602
do not run travis ci on upstream
p-alik Feb 7, 2017
90db6a6
maxque test without client/worker
p-alik Mar 14, 2017
c409a04
rm Gearman::Client specifix test script
p-alik Mar 14, 2017
78d5a8f
v1.140_001
p-alik Mar 14, 2017
35ae718
use Net::EmptyPort
p-alik Mar 14, 2017
00e819c
rm unused dependencies
p-alik Mar 14, 2017
4e0f79a
rm useless module
p-alik Mar 14, 2017
4482d09
more tests
p-alik Mar 14, 2017
69db7b0
changes [skip ci]
p-alik Mar 14, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
language: perl
perl:
- "5.24"
- "5.22"
- "5.20"
- "5.18"
- "5.16"
- "5.14"
- "5.12"
- "5.10"

sudo: false

before_install:
- git clone git://github.com/travis-perl/helpers ~/travis-perl-helpers
- source ~/travis-perl-helpers/init
- build-perl
- perl -V
- build-dist
- cd $BUILD_DIR

install:
- cpanm --quiet --notest Devel::Cover::Report::Coveralls
- cpanm --quiet --notest --installdeps .

script:
- perl Makefile.PL
- make
- PERL5OPT=-MDevel::Cover=-coverage,statement,branch,condition,path,subroutine prove -b -r -s t

after_success:
- cover -test -report coveralls

branches:
only:
- master
18 changes: 17 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
1.14_001 2017-03-14
* no more support for text command shutdown
* more tests

1.13.002 2016-07-11
* pod links to gearmand repaired

1.13.001 2016-07-11
* Feature Request: #115368 for Gearman-Server: Allow bind to specific IP address
* Fix bug #115458 Distributions contain no tests.
Actually only use ok and version tests
* Fix bug #89033 typo fixes
* Fix bug #107045 [PATCH] fix pod whatis
* Fix bug #115350 Uses old port by default (7003) should use 4730
* pod usage

1.12 2014-12-14

* Add HACKING file

* Fix memory leak when clients disconnect (sleeper list isn't pruned).
* Fix bug #70728 memory leak when clients disconnect (sleeper list isn't pruned).
Fixes CPAN RT 70728 (Marsh Yamazaki)

1.11 2010-01-17
Expand Down
3 changes: 0 additions & 3 deletions HACKING

This file was deleted.

10 changes: 9 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
CHANGES
gearmand
MANIFEST This list of files
MANIFEST.SKIP
Makefile.PL
README.md
bin/gearmand
lib/Gearman/Server.pm
lib/Gearman/Server/Client.pm
lib/Gearman/Server/Job.pm
lib/Gearman/Server/Listener.pm
t/00-use.t
t/01-gearman-server.t
t/02-gearman-server-client.t
t/03-maxqueue.t
Makefile.PL
MANIFEST This list of files
MANIFEST.SKIP
Expand Down
50 changes: 40 additions & 10 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,14 +1,44 @@
use ExtUtils::MakeMaker;

# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => 'Gearman::Server',
VERSION_FROM => 'lib/Gearman/Server.pm',
ABSTRACT_FROM => 'lib/Gearman/Server.pm',
EXE_FILES => ['gearmand'],
PREREQ_PM => {
'Gearman::Util' => 0,
'Danga::Socket' => 1.52,
},
AUTHOR => 'Brad Fitzpatrick (brad@danga.com), Brad Whitaker (whitaker@danga.com)',
);
NAME => 'Gearman::Server',
VERSION_FROM => 'lib/Gearman/Server.pm',
ABSTRACT_FROM => 'lib/Gearman/Server.pm',
EXE_FILES => ['bin/gearmand'],
BUILD_REQUIRES => {
"File::Spec" => 0,
"FindBin" => 0,
"IO::Socket::INET" => 0,
"Net::EmptyPort" => 0,
"Proc::Guard" => 0,
"Socket" => 0,
"Sys::Hostname" => 0,
"Test::Exception" => 0,
"Test::More" => 0,
"Test::Script" => 1.12,
"Test::TCP" => 0,
"version" => 0,
},
PREREQ_PM => {
"Danga::Socket" => 1.52,
"Gearman::Util" => 0,
"IO::Socket::INET" => 0,
"Sys::Hostname" => 0,
"version" => 0,
},
AUTHOR =>
'Brad Fitzpatrick (brad@danga.com), Brad Whitaker (whitaker@danga.com)',
META_MERGE => {
'meta-spec' => { version => 2 },
resources => {
repository => {
type => 'git',
url => 'https://github.com/p-alik/Gearman-Server.git',
web => 'https://github.com/p-alik/Gearman-Server',
},
},
},

);
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Gearman::Server
===================

[![CPAN version](https://badge.fury.io/pl/Gearman-Server.png)](https://badge.fury.io/pl/Gearman-Server)
[![Build Status](https://travis-ci.org/p-alik/Gearman-Server.png)](https://travis-ci.org/p-alik/Gearman-Server)
[![Coverage Status](https://coveralls.io/repos/github/p-alik/Gearman-Server/badge.png)](https://coveralls.io/github/p-alik/Gearman-Server)

This repository contains perl implementation of [Gearman](http://gearman.org) daemon

see also
------------
* [Gearman::Client](https://metacpan.org/pod/Gearman::Client) - Client for gearman distributed job system
* [Gearman::Worker](https://metacpan.org/pod/Gearman::Worker) - Worker for gearman distributed job system

140 changes: 66 additions & 74 deletions gearmand → bin/gearmand
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/perl
#!/usr/bin/env perl

=head1 NAME

Expand All @@ -23,15 +23,21 @@ daemonization.
Make the daemon run in the background (good for init.d scripts, bad
for running under daemontools/supervise).

=item --port=7003 / -p 7003
=item --port=4730 / -p 4730

Set the port number, defaults to 7003.
Set the port number, default to 4730.

=item --listen hostname / -L hostname

Address the server should listen on.

Default is

=item --pidfile=/some/dir/gearmand.pid

Write a pidfile when starting up

=item --debug=1
=item --debug

Enable debugging (currently the only debug output is when a client or worker connects).

Expand Down Expand Up @@ -59,9 +65,13 @@ the queue.
Zero (0) means go as fast as possible, but not all at the same time. Similar to -1 on --wakeup, but
is more cooperative in gearmand's multitasking model.

Negative One (-1) means that this event won't happe, so only the initial workers will be woken up to
Negative One (-1) means that this event won't happen, so only the initial workers will be woken up to
handle jobs in the queue.

=item --version

Display the version and exit.

=back

=head1 COPYRIGHT
Expand Down Expand Up @@ -95,116 +105,98 @@ L<Gearman::Client::Async>
package Gearmand;
use strict;
use warnings;

BEGIN {
$^P = 0x200; # Provide informative names to anonymous subroutines
# Provide informative names to anonymous subroutines
$^P = 0x200;
}
use FindBin;
use lib "$FindBin::Bin/lib";

use Gearman::Server;

use Getopt::Long;
use Carp;
use Danga::Socket 1.52;
use IO::Socket::INET;
use Getopt::Long;
use POSIX ();
use Gearman::Util;
use vars qw($DEBUG);
use Pod::Usage;
use Scalar::Util ();

$DEBUG = 0;
use vars qw($DEBUG);

my (
$daemonize,
$nokeepalive,
$notify_pid,
$opt_pidfile,
$accept,
$wakeup,
$wakeup_delay,
);
my $conf_port = 7003;

Getopt::Long::GetOptions(
'd|daemonize' => \$daemonize,
'p|port=i' => \$conf_port,
'debug=i' => \$DEBUG,
'pidfile=s' => \$opt_pidfile,
'accept=i' => \$accept,
'wakeup=i' => \$wakeup,
'wakeup-delay=f' => \$wakeup_delay,
'notifypid|n=i' => \$notify_pid, # for test suite only.
);
$DEBUG = 0;
my $port = 4730;

GetOptions(
'accept=i' => \my $accept,
'debug' => \$DEBUG,
'd|daemonize' => \my $daemonize,
'listen|L=s' => \my $listen,
'pidfile=s' => \my $opt_pidfile,
'p|port=i' => \$port,
'wakeup-delay=f' => \my $wakeup_delay,
'wakeup=i' => \my $wakeup,
'version|V' => sub {
print "Gearman::Server $Gearman::Server::VERSION$/";
exit;
},
'help|?' => sub {
pod2usage(-verbose => 1);
exit;
},

# for test suite only.
'notifypid|n=i' => \my $notify_pid,
);

daemonize() if $daemonize;

# true if we've closed listening socket, and we're waiting for a
# convenient place to kill the process
our $graceful_shutdown = 0;

$SIG{'PIPE'} = "IGNORE"; # handled manually

# handled manually
$SIG{'PIPE'} = "IGNORE";
my $server = Gearman::Server->new(
wakeup => $wakeup,
wakeup_delay => $wakeup_delay,
);
my $ssock = $server->create_listening_sock($conf_port, accept_per_loop => $accept);
wakeup => $wakeup,
wakeup_delay => $wakeup_delay,
);
my $ssock = $server->create_listening_sock(
$port,
accept_per_loop => $accept,
local_addr => $listen
);

if ($opt_pidfile) {
open my $fh, '>', $opt_pidfile or die "Could not open $opt_pidfile: $!";
print $fh "$$\n";
close $fh;
}

sub shutdown_graceful {
return if $graceful_shutdown;

my $ofds = Danga::Socket->OtherFds;
delete $ofds->{fileno($ssock)};
$ssock->close;
$graceful_shutdown = 1;
shutdown_if_calm();
}

sub shutdown_if_calm {
exit 0 unless $server->jobs_outstanding;
}

sub daemonize {
my ($pid, $sess_id, $i);

my ($pid, $sess_id);
## Fork and exit parent
if ($pid = fork) { exit 0; }

## Detach ourselves from the terminal
croak "Cannot detach from controlling terminal"
unless $sess_id = POSIX::setsid();

## Prevent possibility of acquiring a controling terminal
## Prevent possibility of acquiring a controlling terminal
$SIG{'HUP'} = 'IGNORE';
if ($pid = fork) { exit 0; }

## Change working directory
chdir "/";
chdir("/") || croak "can't chdir to /: $!";

## Clear file creation mask
umask 0;

## Close open file descriptors
close(STDIN);
close(STDOUT);
close(STDERR);
close(STDIN) || croak "can't close STDIN: $!";
close(STDOUT) || croak "can't close STDOUT: $!";
close(STDERR) || croak "can't close STDERR: $!";

## Reopen stderr, stdout, stdin to /dev/null
open(STDIN, "+>/dev/null");
open(STDOUT, "+>&STDIN");
open(STDERR, "+>&STDIN");
}
open(STDIN, "+>/dev/null") || croak "can't write to /dev/null: $!";
open(STDOUT, "+>&STDIN") || croak "can't dup STDOUT to STDIN: $!";
open(STDERR, "+>&STDIN") || croak "can't dup STDERR to STDIN: $!";
} ## end sub daemonize

kill 'USR1', $notify_pid if $notify_pid;
Danga::Socket->EventLoop();

# Local Variables:
# mode: perl
# c-basic-indent: 4
# indent-tabs-mode: nil
# End:
Loading