Welcome! Log In Create A New Profile

Advanced

Re: Request inside a timer

Peter Leonov
February 17, 2012 02:32PM
Well done by the way! :)

On 11.02.2012, at 3:04, Alexandr Gomoliako <zzz@zzz.org.ua> wrote:

> On Sat, Feb 11, 2012 at 12:39 AM, António P. P. Almeida
> <appa@perusio.net> wrote:
>>> I would like to do a module which, at some interval, refresh part of
>>> its configuration getting some values from a external service. So I
>>> need to make a GET independent of a user request.
>>
>> I suggest not doing a module, but instead making use of:
>>
>> http://wiki.nginx.org/HttpLuaModule
>>
>> It can do that and more, much more.
>
> I don't think it can. But pretty easy with Nginx::Perl:
>
> use Nginx;
> use Nginx::HTTP;
>
> sub init_worker {
> ...
> my $req = "GET / HTTP/1.1" . "\x0d\x0a" . "Host: foobar" .
> "\x0d\x0a\x0d\x0a" ;
>
> ngx_timer 0, 5, sub {
> ngx_http "1.2.3.4:80", $req, sub {
> my ($headers, $buf_ref) = @_;
>
> unless ($headers) {
> ngx_log_error $!, "error";
> return;
> }
>
> ngx_log_notice 0, "got $headers->{'_status'}";
> ...
> };
> };
> }
>
> http://zzzcpan.github.com/nginx-perl/
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Request inside a timer

wandenberg 1668 February 10, 2012 03:46PM

Re: Request inside a timer

António P. P. Almeida 573 February 10, 2012 05:40PM

Re: Request inside a timer

Alexandr Gomoliako 563 February 10, 2012 06:06PM

Re: Request inside a timer

António P. P. Almeida 605 February 10, 2012 06:38PM

Re: Request inside a timer

Alexandr Gomoliako 533 February 10, 2012 07:00PM

Re: Request inside a timer

wandenberg 654 February 13, 2012 09:04PM

Re: Request inside a timer

Alexandr Gomoliako 568 February 13, 2012 09:44PM

Re: Request inside a timer

Peter Leonov 653 February 17, 2012 02:32PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 221
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready