gearman perl 测试

前端之家收集整理的这篇文章主要介绍了gearman perl 测试前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
perl gearman 测试 1)安装 wget -c http://launchpadlibrarian.net/51244438/gearmand-0.14.tar.gz   tar zxvf gearmand-0.14.tar.gz   cd gearmand-0.14   ./configure   make && make install   cpan -i Gearman::Server cpan -i Gearman::Worker cpan -i Gearman::Client 2)启动gearmand   gearmand -d -L 10.16.27.32 -p 7003   3)书写worker.pl #!/usr/bin/perl -w use Gearman::Worker;   my $worker = Gearman::Worker->new; $worker->job_servers('10.16.27.32:7003'); $worker->register_function( watchtime => \&watchtime ); $worker->work while 1;   sub watchtime {   my $job= shift;        return "arg=".$job->arg; }    perl worker.pl 4)书写client.pl  #!/usr/bin/perl -w use Gearman::Client; use POSIX qw(strftime);   my $client = Gearman::Client->new; $client->job_servers('10.16.27.32:7003'); my $log=$client->do_task('watchtime',"aaaa"); print $$log,"\n"; $log=$client->do_task('watchtime',"aaaabbb"); print $$log,"\n"; 执行client.pl,可看到返回数据

猜你在找的Perl相关文章