[Mojolicious] Can't locate object method "delay" via package "Mojolicious::Controller"

2014-11-29 Thread Pavel Serikov
Hello everyone,

I'm writing test application with OAuth2 using Mojolicious::Plugin::Oauth2 
 asynchronius request 
to API and I've got a strange error

[error] Can't locate object method "delay" via package 
> "Mojolicious::Controller" at oauth2 line 40.
>

Here is my code:

#!/usr/bin/env perl
use Mojolicious::Lite;
use Mojolicious::Plugin::OAuth2;
use IO::Socket::SSL;

plugin 'OAuth2', {
   facebook => {
   key => "xxx",
   secret => "xxx",
}
};

get "/auth" => sub {
my $self = shift;
$self->delay(
  sub {
my $delay = shift;
$self->get_token(facebook => $delay->begin);
  },
  sub {
my($delay, $token, $tx) = @_;
return $self->render(text => $tx->res->error) unless $token;
$self->session(token => $token);
$self->render(text => $token);
  });
};


app->start;


What's wrong? Is delay() 
 
method already outdated?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Can't locate object method "delay" via package "Mojolicious::Controller"

2014-11-30 Thread Pavel Serikov
Dear Sebastian,

Could you please help me to understood where is the problem?

I've read docs again and found that *delay()* method refers to 
DefaultHelpers 
. I've 
tried to include it manually as in synopsis assuming that it isn't included 
by default, but still I've got same error:

Can't locate object method "delay" via package "Mojolicious::Controller"



-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Re: Can't locate object method "delay" via package "Mojolicious::Controller"

2014-11-30 Thread Pavel Serikov
Hi Alex,

The output is

4.63



воскресенье, 30 ноября 2014 г., 14:23:31 UTC+3 пользователь Alex Alex 
написал:
>
>  Maybe u r using an outdated version?
>
> Give us an output of:
> perl -MMojolicious -e 'print Mojolicious->VERSION. "\n"'
>
>  Dear Sebastian, 
>
>  Could you please help me to understood where is the problem?
>
>  I've read docs again and found that *delay()* method refers to 
> DefaultHelpers 
> . 
> I've tried to include it manually as in synopsis assuming that it isn't 
> included by default, but still I've got same error:
>
>  Can't locate object method "delay" via package "Mojolicious::Controller"
>
>
>  
>  -- 
> You received this message because you are subscribed to the Google Groups 
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to mojolicious...@googlegroups.com .
> To post to this group, send email to mojol...@googlegroups.com 
> .
> Visit this group at http://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>
>
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Re: Can't locate object method "delay" via package "Mojolicious::Controller"

2014-11-30 Thread Pavel Serikov
Hi Alex,

The output is

4.63

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Re: Can't locate object method "delay" via package "Mojolicious::Controller"

2014-11-30 Thread Pavel Serikov
Thank you. I've updated version and now everything works fine :)

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] How to use string as a subroutine ref in Mojo?

2014-12-12 Thread Pavel Serikov
Hi everyone,

I need to pass as input parameter of one function name of other function 
which must be executed in some cases. But cause of Mojolicious uses 'strict 
refs' I have no idea how to do it :(

Can you please advice me something?

For better understanding problem let me give an example:

#!/usr/bin/env perl
my $i = "test";
sub test {
print "Hello World!\n";
}
$i->();
this code works fine

#!/usr/bin/env perl
use Mojolicious::Lite;
my $i = "test";
sub test {
print "Hello World!\n";
}
$i->();
and this doesn't :(

Is this a bug or it's a feature?

Any suggestion is much appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] How to use string as a subroutine ref in Mojo?

2014-12-12 Thread Pavel Serikov
Hi Sebastian,

Thank you very much.

Actually working solution is:
my $a = "test";
sub test {
print "Hello World!\n";
}
my $b = \&$a;
$b->();

I hope that this code is considered as good style :)

And the real question that needs to be answered first is "What are you 
> actually trying to achieve?".


Actually I am writing some helpers for working with one API. Example below 
shows why i need to use function name as parameter (string):

sub api_abstraction {
my ($timeout, $params, $is_form, $name_of_parse_function, $is_render) = 
@_;
# ...
my $a = \&$name_of_parse_function;
$a->();
}

sub parser1 {
print "Hello World!\n";
# ...
}

sub parser2 {
print "Obama eats children!\n";
# ...
}

my $hash = api_abstraction(7, {product => 'phone', sn => '0001'}, 1, 
'parser2', 1);


-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] What it the right syntax for checking POST requests from command line (after -c key) ?

2015-04-16 Thread Pavel Serikov
Hello collegues,

I need to check my API from command line, but I haven't found any manual 
how to do it correctly. Let me explain problem on example:

I have POST handler:

#!/usr/bin/env perl
use Mojolicious::Lite;

post '/' => sub {
 my $self = shift;
 warn $self->param("email");
 ...
 # warn $something_else
 $self->render({text => 'OK'});
};


And I need to check correcthess of parameters processing. In this simple 
example task is just output in console value of email parameter like GET 
way:

./api.pl get /?email='t...@test.ru'

And how to do it with POST requests?

In help file there is only one example with POST:

mojo get -M POST -c 'trololo' mojolicio.us

And usage is: APPLICATION get [OPTIONS] URL [SELECTOR|JSON-POINTER] [COMMANDS]

Options:
  -C, --charset  Charset of HTML/XML content, defaults to auto
  detection.
  -c, --content  Content to send with request.
  -H, --headerAdditional HTTP header.
  -M, --methodHTTP method to use, defaults to "GET".
  -r, --redirect  Follow up to 10 redirects.
  -v, --verbose   Print request and response headers to STDERR. 

But how to be if after -c key not a simple string like "trololo", but there are 
some parameters?

I tried this way:

./api.pl get -M POST -c 'email=test@test' /
./api.pl get -M POST -c '{email=>test@test}' /


But both of them doesn't work.

Any suggestion is much appreciated.






-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] How to upload files on server using Mojo::UserAgent::Transactor?

2015-04-20 Thread Pavel Serikov
Greetings,

I need to upload files on server using Mojo

Can anyone explain me how to do it on simple example below?

I run with morbo on http://127.0.0.1:3000 this app:

#!/usr/bin/env perl
use Mojolicious::Lite;

post '/' => sub {
  my $self = shift;
  my $upload = $self->param('model');
  my $name = $upload->filename;
  warn $name;
  $self->render(text => 'OK');
};

app->start;

And run this file upload script (called it test.pl):

use Mojo::UserAgent::Transactor;
use Data::Dumper;

my $t = Mojo::UserAgent::Transactor->new;
my $tx = $t->tx(POST => 'http://127.0.0.1:3000' => form => {model => {file 
=> 'stick.stl'}});
my $result = $tx->res->to_string;
warn Dumper $result;

on output of ./test.pl I have:
 
$VAR1 = 'HTTP/1.1 404 Not Found
Content-Length: 0
Date: Tue, 21 Apr 2015 05:37:21 GMT
';

And no one warn output in server log, only regular

[Tue Apr 21 09:33:24 2015] [info] Listening at "http://*:3000";.
> Server available at http://127.0.0.1:3000.


What I did wrong?



-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Is there any way to access all request parameters in Mojolicious::Lite ?

2015-05-28 Thread Pavel Serikov


Hello everyone,

Is it possible to get all POST params im Mojolicious::Lite 
 like in Mojolicious 
? Like this:

my $param = $self->req->params->to_hash;

I tried this way :

my @params = $self->param;

But Dumper show me an empty array despite I can access each param via 
$self->param("")



-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Is there any way to access all request parameters in Mojolicious::Lite ?

2015-05-28 Thread Pavel Serikov
Great, it works, thank you :)

But how to access params if they are files?

E.g. i'm sending such hash:

my %hash = (
city => "Rostov-on-Don",
model => {file => "stick.stl"},
image => {file => "test.jpg"},
promo => "TEST",
);

And *$self->req->params->names* will show only *[city, promo]*.


пятница, 29 мая 2015 г., 3:58:12 UTC+4 пользователь Dan Book написал:
>
> That Wiki page is outdated, you now access param names by: my $params = 
> $self->req->params->names; (returns an arrayref)
>
> From Mojolicious or Mojolicious::Lite works the same.
>
> On Thu, May 28, 2015 at 7:45 PM, Pavel Serikov  > wrote:
>
>> Hello everyone,
>>
>> Is it possible to get all POST params im Mojolicious::Lite 
>> <https://metacpan.org/pod/Mojolicious::Lite> like in Mojolicious 
>> <https://metacpan.org/pod/Mojolicious>? Like this:
>>
>> my $param = $self->req->params->to_hash;
>>
>> I tried this way <https://github.com/kraih/mojo/wiki/Request-data>:
>>
>> my @params = $self->param;
>>
>> But Dumper show me an empty array despite I can access each param via 
>> $self->param("")
>>
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Mojolicious" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to mojolicious...@googlegroups.com .
>> To post to this group, send email to mojol...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/mojolicious.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Mojo::UserAgent doesn't work?

2015-06-27 Thread Pavel Serikov
Hello dear colleagues,

Can someone tell me why this script doesn't work?

#!/usr/bin/env perl
use Mojo::UserAgent;
use feature 'say';
use utf8;

my $ua = Mojo::UserAgent->new;
say $ua->get('http://geocode-maps.yandex.ru/1.x/?geocode=Moscow&format=json'
)->res->json->{response}->{GeoObjectCollection}->{featureMember}->[0]->{
GeoObject}->{metaDataProperty}->{GeocoderMetaData}->{AddressDetails}->{
Country}->{CountryName};

When I run script I got such error:

pavel@U310T:~/projects/test_scripts$ ./test_geocode.pl
> Can't use an undefined value as a HASH reference at ./test_geocode.pl line 
> 8.
>

And seems like problem isn't in JSON structure or wrong Yandex API string. 
When I modified script to:

#!/usr/bin/env perl
use Mojo::UserAgent;
use Data::Dumper;
use utf8;
my $ua = Mojo::UserAgent->new;
warn Dumper $ua->get(
'https://geocode-maps.yandex.ru/1.x/?geocode=Moscow&format=json')->res->json
;

I got:

pavel@U310T:~/projects/test_scripts$ ./test_geocode.pl
> $VAR1 = undef;
>

And as you can make sure API is working - 
https://geocode-maps.yandex.ru/1.x/?geocode=Moscow&format=json

My Mojo version is latest

sudo cpan -D Mojolicious
> Loading internal null logger. Install Log::Log4perl for logging messages
> Reading '/home/pavel/.cpan/Metadata'
>   Database was generated on Sat, 27 Jun 2015 04:41:02 GMT
> Mojolicious
> -
> (no description)
> D/DB/DBOOK/Mojolicious-6.12.tar.gz
> /usr/local/share/perl/5.18.2/Mojolicious.pm
> Installed: 6.12
> CPAN:  6.12  up to date
> Sebastian Riedel (SRI)
> kra...@googlemail.com
>

I'm quite confused, cause recently this script worked... I didn't anything 
except updating Mojolicious to latest version.

Any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Mojo::UserAgent doesn't work?

2015-06-27 Thread Pavel Serikov
Hello Sergey.

Yes, I got json from Yandex Maps API. 
With wget and curl it's working, but I need to realize it with UserAgent 
get() method. 
I suppose that it's a bug of latest versions. Cause in 5.50 everything 
works ok. So let's wait maintainer's answer.

суббота, 27 июня 2015 г., 12:53:27 UTC+3 пользователь Sergey Andreev 
написал:
>
> Did you got json from another app? Try curl or wget same url, for me your 
> script return json.
> On Jun 27, 2015 4:44 PM, "Pavel Serikov"  > wrote:
>
>> Hello dear colleagues,
>>
>> Can someone tell me why this script doesn't work?
>>
>> #!/usr/bin/env perl
>> use Mojo::UserAgent;
>> use feature 'say';
>> use utf8;
>>
>> my $ua = Mojo::UserAgent->new;
>> say $ua->get('
>> http://geocode-maps.yandex.ru/1.x/?geocode=Moscow&format=json')->res->
>> json->{response}->{GeoObjectCollection}->{featureMember}->[0]->{GeoObject
>> }->{metaDataProperty}->{GeocoderMetaData}->{AddressDetails}->{Country}->{
>> CountryName};
>>
>> When I run script I got such error:
>>
>> pavel@U310T:~/projects/test_scripts$ ./test_geocode.pl
>>> Can't use an undefined value as a HASH reference at ./test_geocode.pl 
>>> line 8.
>>>
>>
>> And seems like problem isn't in JSON structure or wrong Yandex API 
>> string. When I modified script to:
>>
>> #!/usr/bin/env perl
>> use Mojo::UserAgent;
>> use Data::Dumper;
>> use utf8;
>> my $ua = Mojo::UserAgent->new;
>> warn Dumper $ua->get('
>> https://geocode-maps.yandex.ru/1.x/?geocode=Moscow&format=json')->res->
>> json;
>>
>> I got:
>>
>> pavel@U310T:~/projects/test_scripts$ ./test_geocode.pl
>>> $VAR1 = undef;
>>>
>>
>> And as you can make sure API is working - 
>> https://geocode-maps.yandex.ru/1.x/?geocode=Moscow&format=json
>>
>> My Mojo version is latest
>>
>> sudo cpan -D Mojolicious
>>> Loading internal null logger. Install Log::Log4perl for logging messages
>>> Reading '/home/pavel/.cpan/Metadata'
>>>   Database was generated on Sat, 27 Jun 2015 04:41:02 GMT
>>> Mojolicious
>>> -
>>> (no description)
>>> D/DB/DBOOK/Mojolicious-6.12.tar.gz
>>> /usr/local/share/perl/5.18.2/Mojolicious.pm
>>> Installed: 6.12
>>> CPAN:  6.12  up to date
>>> Sebastian Riedel (SRI)
>>> kra...@googlemail.com 
>>>
>>
>> I'm quite confused, cause recently this script worked... I didn't 
>> anything except updating Mojolicious to latest version.
>>
>> Any ideas?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Mojolicious" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to mojolicious...@googlegroups.com .
>> To post to this group, send email to mojol...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/mojolicious.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Mojo::UserAgent doesn't work?

2015-06-27 Thread Pavel Serikov
Yeah, it's working :)

But *warn Dumper 
($ua->get('http://geocode-maps.yandex.ru/1.x/?geocode=Москва&format=json')->res->json)
 
*doesn't. $VAR1 = undef

So problem is in res->json method?

суббота, 27 июня 2015 г., 12:59:51 UTC+3 пользователь Bernhard Graf написал:
>
> You simply didn't get a JSON response. Try 
>
> warn 
> Dumper($ua->get('
> https://geocode-maps.yandex.ru/1.x/?geocode=Moscow&format=json')->res) 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Mojo::UserAgent doesn't work?

2015-07-15 Thread Pavel Serikov
Thanks all for your suggestions.

Yeah, it first script I forgot to use https instead of http (or use 
$ua->max_redirects ).

And in second script updating Mojo from 6.12 to 6.14 was solved the problem 
:)


воскресенье, 28 июня 2015 г., 1:23:53 UTC+3 пользователь Dan Book написал:
>
> To follow redirects, set 
> https://metacpan.org/pod/Mojo::UserAgent#max_redirects
>
> On Sat, Jun 27, 2015 at 6:15 PM, Stefan Adams  > wrote:
>
>>
>> On Sat, Jun 27, 2015 at 5:10 AM, Pavel Serikov > > wrote:
>>
>>> Yeah, it's working :)
>>>
>>> But *warn Dumper 
>>> ($ua->get('http://geocode-maps.yandex.ru/1.x/?geocode=Москва&format=json')- 
>>> <http://geocode-maps.yandex.ru/1.x/?geocode=%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D0%B0&format=json')->>res->json)
>>>  
>>> *doesn't. $VAR1 = undef
>>>
>>> So problem is in res->json method?
>>>
>>
>> Notice Bernhard's URL had *https*.  The http URL you supplied returns a 
>> 301 redirect to *https*, which of course the 301 response has no JSON in 
>> the response.
>>
>> $ perl -MData::Dumper -MMojo::UserAgent -E 'warn Dumper 
>> (Mojo::UserAgent->new->get(q(
>> https://geocode-maps.yandex.ru/1.x/?geocode=Moscow&format=json))-
>> >res->json)'
>> $VAR1 = {
>>   'response' => {
>> ...
>>   }
>> };
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Mojolicious" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to mojolicious...@googlegroups.com .
>> To post to this group, send email to mojol...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/mojolicious.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Mojo::UserAgent log and timeouts

2015-07-15 Thread Pavel Serikov
Hi guys,

Here is a description of new problem which I don't understand how to solve.

I need to use Mojo::UserAgent to parse data from Wordpress site via WP-API 
.

If I use browser (just to verify that API url works correctly) - it works.

E.g. this url 
http://klishe.ru/wp-json/posts?filter[post_status]=publish&filter[category_name]=производители&filter[posts_per_page]=-1&filter[nopaging]=true&filter[order]=ASC
 
must return 446 json objects.

Checked it with javascript:
var obj = JSON.parse(document.body.textContent);
console.log(obj.length);

But if I use Mojo::UserAgent for getting data from same url - it returns 
nothing.

Below is my Mojo script:

#!/usr/bin/env perl

use common::sense;
use Mojo::UserAgent;
use feature 'say';

my $ua = Mojo::UserAgent->new;
#$ua->connect_timeout(0);
#$ua->request_timeout(0);
my $url = 
'http://klishe.ru/wp-json/posts?filter[post_status]=publish&filter[category_name]=производители&filter[posts_per_page]=-1&filter[nopaging]=true&filter[order]=ASC'
;
my $companies = $ua->get($url)->res->json;
say scalar @$companies;

If I modify API url to limit numbers of returned objects (from 
filter[posts_per_page]=*-1* to filter[posts_per_page]=*150* ) everything 
works fine.

I suppose that I need to increase some timeouts, but have no idea what 
exact. I tried to set different connect_timeout 
 and 
request_timeout , 
but even with unlimited timeouts it doesn't give any result. Also checked 
values of MOJO_CONNECT_TIMEOUT, MOJO_REQUEST_TIMEOUT and 
MOJO_INACTIVITY_TIMEOUT system variables, it isn't set.

My Mojo is latest stable version, 6.14.

Any suggestion is much appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Mojo::UserAgent log and timeouts

2015-07-16 Thread Pavel Serikov
Hi Dan,

Absolutely agree with you about urlencoding, but it doesn't make a 
difference in this case.

#!/usr/bin/env perl

use common::sense;
use Mojo::UserAgent;
use feature 'say';

my $ua = Mojo::UserAgent->new;
my $url = Mojo::URL->new('http://klishe.ru/wp-json/posts')->query(
'filter[category_name]' => 'производители', 'filter[posts_per_page]' => '-1'
, 'filter[nopaging]' =>'true', 'filter[order]' => 'ASC');
my $companies = $ua->get($url)->res->json;
say scalar @$companies;


If I change to *filter[posts_per_page]' => '150'* in script above - it 
works.

Does the Mojo::UserAgent have any log to see what's wrong and what's an 
error message?





среда, 15 июля 2015 г., 16:33:29 UTC+3 пользователь Dan Book написал:
>
> Your URL parameters are not being url encoded as required. Use a Mojo::URL 
> instead:
>
> my $url = 
> Mojo::URL->new('http://klishe.ru/wp-json/posts')->query('filter[post_status]' 
> => 'publish', ...);
>
>
> On Wed, Jul 15, 2015 at 7:35 AM, Pavel Serikov  > wrote:
>
>> Hi guys,
>>
>> Here is a description of new problem which I don't understand how to 
>> solve.
>>
>> I need to use Mojo::UserAgent to parse data from Wordpress site via 
>> WP-API <http://wp-api.org/>.
>>
>> If I use browser (just to verify that API url works correctly) - it works.
>>
>> E.g. this url 
>> http://klishe.ru/wp-json/posts?filter[post_status]=publish&filter[category_name]=производители&filter[posts_per_page]=-1&filter[nopaging]=true&filter[order]=ASC
>>  
>> must return 446 json objects.
>>
>> Checked it with javascript:
>> var obj = JSON.parse(document.body.textContent);
>> console.log(obj.length);
>>
>> But if I use Mojo::UserAgent for getting data from same url - it returns 
>> nothing.
>>
>> Below is my Mojo script:
>>
>> #!/usr/bin/env perl
>>
>> use common::sense;
>> use Mojo::UserAgent;
>> use feature 'say';
>>
>> my $ua = Mojo::UserAgent->new;
>> #$ua->connect_timeout(0);
>> #$ua->request_timeout(0);
>> my $url = '
>> http://klishe.ru/wp-json/posts?filter[post_status]=publish&filter[category_name]=производители&filter[posts_per_page]=-1&filter[nopaging]=true&filter[order]=ASC
>> ';
>> my $companies = $ua->get($url)->res->json;
>> say scalar @$companies;
>>
>> If I modify API url to limit numbers of returned objects (from 
>> filter[posts_per_page]=*-1* to filter[posts_per_page]=*150* ) everything 
>> works fine.
>>
>> I suppose that I need to increase some timeouts, but have no idea what 
>> exact. I tried to set different connect_timeout 
>> <https://metacpan.org/pod/Mojo::UserAgent#connect_timeout> and 
>> request_timeout 
>> <https://metacpan.org/pod/Mojo::UserAgent#request_timeout>, but even 
>> with unlimited timeouts it doesn't give any result. Also checked values of 
>> MOJO_CONNECT_TIMEOUT, 
>> MOJO_REQUEST_TIMEOUT and MOJO_INACTIVITY_TIMEOUT system variables, it isn't 
>> set.
>>
>> My Mojo is latest stable version, 6.14.
>>
>> Any suggestion is much appreciated.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Mojolicious" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to mojolicious...@googlegroups.com .
>> To post to this group, send email to mojol...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/mojolicious.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Mojo::UserAgent log and timeouts

2015-07-16 Thread Pavel Serikov
Hi Stefan, could you please tell me where did you see that two errors 
("Maximum header size exceeded" and "Inactivity timeout")? How did you 
debug Mojo::UserAgent request?

P.S. Thank you for idea with curl, I will try that.

четверг, 16 июля 2015 г., 18:30:59 UTC+3 пользователь Stefan Adams написал:
>
>
> On Thu, Jul 16, 2015 at 2:56 AM, Pavel Serikov  > wrote:
>
>> If I change to *filter[posts_per_page]' => '150'* in script above - it 
>> works.
>>
>> Does the Mojo::UserAgent have any log to see what's wrong and what's an 
>> error message?
>>
>
> I'm seeing two errors: "Maximum header size exceeded" and "Inactivity 
> timeout"
>
> With the -1 parameter value, you're asking for a lot from the server.  
> It's taking around 20 seconds.  You might need to increase the 
> MOJO_INACTIVITY_TIMEOUT environment variable to greater than 20 seconds.
>
> For the maximum header size exceeded, I'm seeing some weird stuff in the 
> header.  Use curl to inspect the raw header:
>
> $ curl -I -g '
> http://klishe.ru/wp-json/posts?filter[post_status]=publish&filter[category_name]=производители&filter[posts_per_page]=-1&filter[nopaging]=true&filter[order]=ASC
> '
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Mojolicious::Lite websocket doens't work

2015-10-19 Thread Pavel Serikov
Hi everyone,
I need a simple app which got POST request and send its content through 
websocket to all connected browser clients.

I wrote a code,

#!/usr/bin/env perl
use Mojolicious::Lite;
use feature 'say';

my $clients = {};
my $curr_msg = {};

post '/' => sub {
  my $self = shift;
  my $params = $self->req->params->names;
  for (@$params) {
$curr_msg->{$_} = $self->param($_);
  };
  $self->render(json => { status => 'post ok', data => $curr_msg});  
};

websocket '/ws' => sub {
my $self = shift;
app->log->debug(sprintf 'Client connected: %s', $self->tx);
my $id = sprintf "%s", $self->tx;
$clients->{$id} = $self->tx;

if (%$curr_msg) {
  for (keys %$clients) {
  $clients->{$_}->send(json => $curr_msg);
   };
   $curr_msg = {};
};

$self->on(finish => sub {
app->log->debug('Client disconnected');
delete $clients->{$id};
});
};

app->start;

But for some reason it doesn't work - not sending json to clients. I have 
no idea why and how to debug.
Does anyone see any bad things in my code?

Any suggestion is much appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Mojolicious::Lite websocket doens't work

2015-10-20 Thread Pavel Serikov
Dear Sebastian, thank you for your reply.
I used your example and modified mine (result 
) for using with 
Mojo::EventEmitter, now everything works fine.

Could you please also explain, what do I need to store in database (pub/sub 
backend like PostgreSQL or Redis) in case of scalable solution?

вторник, 20 октября 2015 г., 0:21:58 UTC+3 пользователь sri написал:
>
> There's example applications for this.
>
> https://github.com/kraih/mojo/blob/master/examples/chat.pl
> https://github.com/kraih/mojo-pg/blob/master/examples/chat.pl
>
> For a scalable solution you'll need a pub/sub backend like PostgreSQL or 
> Redis.
>
> --
> sebastian
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Mojolicious::Lite doesn't serve static files from '/public' directory automatically

2015-10-21 Thread Pavel Serikov
I created "public" folder into my project and put js and css files into it. 
But for some reason morbo doesn't serve them, it's shown 404 code in 
browser console network tab.
Is documentation 
 
outdated?

I have Mojolicious v 6.20 and "public" folder has all permissions.

What is wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Mojolicious::Lite doesn't serve static files from '/public' directory automatically

2015-10-21 Thread Pavel Serikov
You suggest generation of full app, I need a lite app.

Did generation this way:

$ mojo generate lite_app 



четверг, 22 октября 2015 г., 1:16:01 UTC+3 пользователь Stefan Adams 
написал:
>
> I might suggest you start with a generated app, run that for personal 
> verification, and then compare that (which works) with yours (which 
> doesn't).
>
> $ mojo generate app
>
> On Wed, Oct 21, 2015 at 3:58 PM, Pavel Serikov  > wrote:
>
>> I created "public" folder into my project and put js and css files into 
>> it. 
>> But for some reason morbo doesn't serve them, it's shown 404 code in 
>> browser console network tab.
>> Is documentation 
>> <http://mojolicio.us/perldoc/Mojolicious/Guides/Tutorial#Static-files> 
>> outdated?
>>
>> I have Mojolicious v 6.20 and "public" folder has all permissions.
>>
>> What is wrong?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Mojolicious" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to mojolicious...@googlegroups.com .
>> To post to this group, send email to mojol...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/mojolicious.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Continiuos Intergation for Mojolicious projects

2015-10-29 Thread Pavel Serikov
Hi all, 

What CI tool are you using?

I'm looking for tool with simple web interface that allow me to manage 
deployment 
process.

My typical scenario:
Push to Github repository -> Triggered by webhook main server do automatic 
git fetch -> run tests -> if tests paased ok  run git checkout  -> run 
deployment scripts (db migration, hypnotoad reload, post-checkout hook etc.)

So desirable features is:
- Git SCM support
- Bitbucket, Github and Gitlab integration support
- Opensource and free for usage at own server
- Run and show results of tests (Test::Mojo support)
- Autodeploy project if all tests passed ok
- Simple web interface for manage matching remote and local repository, 
deployment keys etc.

Already looked to Buildbot , Codeship 
, Travis CI  and doing some 
testing now, but want to know commutity at first :)

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Good way to use result of rendering one route in another route at Mojolicious::Lite?

2015-11-14 Thread Pavel Serikov
E.g I want to use json which is the result of rendering one route in 
forming output of another route. To make code in my CRUD app less and more 
reusable.

Something like this:

get '/api/:coll/:id' => sub {
   ...
   if ($self->param("coll") eq "lists") {
  ...
  push @{$o->{items}}, $self->ua->get('/api/items/'.$_->{item_id})->res
->json;
  ...

Now I'm using Mojo::UserAgent  
default 
helper  
for this. Is it a good way or is there any alternatives?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] How to test CRUD app using Test::Mojo ?

2015-11-18 Thread Pavel Serikov
How to capture output of one route and then use it in test for another 
route?

E.g. this algorithm of test:

1) got *$object_id* as result of post_ok 
  (CREATE, post '/api/:coll' 
route)
2) use this *$object_id* in put_ok 
   (UPDATE same object, put 
'/api/:coll/:id' route)
3) use it (or other param) in get_ok 

4) .. delete_ok 

etc.

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Is Mojo::DOM cut url parameters?

2015-12-29 Thread Pavel Serikov
Hello,

I exctracted all url from page via

my @a = $body->find("a[href]")->each; # $body = Mojo::DOM object
 for (@a) {
  say $_->attr("href");
 }

And for 

result is:
http:///userfiles.php

Why is it cut ?userId=6211 and how to get it?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Possible bug of hypnotoad (or problem with nginx or css relative path)

2016-01-13 Thread Pavel Serikov
Hello colleagues,

I have a quite unpleasant problem: Glypicons can't be loaded on production 
instance though at localhost it's working fine.

In Chrome console I see that server request files by 
*http://domain_name/fonts/glyphicons-halflings-regular.ttf* address, but in 
fact file stored at 
*public/vendor/bootstrap-3.3.6-dist/fonts/glyphicons-halflings-regular.ttf* 
catalog. 
So* /vendor/bootstrap-3.3.6-dist/* part of url somehow is missed.

All other css and js files at production instance are loading normally.

.../public/vendor/bootstrap-3.3.6-dist# ls -la
total 20
drwxrwxrwx 5 root root 4096 Jan 12 11:53 .
drwxr-xr-x 3 root root 4096 Jan 12 11:53 ..
drwxrwxrwx 2 root root 4096 Jan 12 11:53 css
drwxrwxrwx 2 root root 4096 Jan 12 11:53 fonts
drwxrwxrwx 2 root root 4096 Jan 12 11:53 js


At bootstrap.css glyphicons are loaded via relative path like:

@font-face {
  font-family: 'Glyphicons Halflings';
  src: url('../fonts/glyphicons-halflings-regular.eot');
..

Can it be the problem? Or I need to add something in nginx domain config? 
Or it's bug of hypnotoad?
The difference between production instance and development localhost only 
that on localhost I'm using morbo and on production server I use 
hypnotoad+nginx.
If I run my project under morbo on production server it also works fine.

I'm using Mojolicious v. 6.11

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Possible bug of hypnotoad (or problem with nginx or css relative path)

2016-01-13 Thread Pavel Serikov
Seems like it really was a bug of hypnotoad.
I updated Mojolicious to latest version (6.39) and now everything works 
fine! :)
Case closed.


среда, 13 января 2016 г., 15:19:13 UTC+3 пользователь Pavel Serikov написал:
>
> Hello colleagues,
>
> I have a quite unpleasant problem: Glypicons can't be loaded on production 
> instance though at localhost it's working fine.
>
> In Chrome console I see that server request files by 
> *http://domain_name/fonts/glyphicons-halflings-regular.ttf 
> <http://domain_name/fonts/glyphicons-halflings-regular.ttf>* address, but 
> in fact file stored at 
> *public/vendor/bootstrap-3.3.6-dist/fonts/glyphicons-halflings-regular.ttf* 
> catalog. 
> So* /vendor/bootstrap-3.3.6-dist/* part of url somehow is missed.
>
> All other css and js files at production instance are loading normally.
>
> .../public/vendor/bootstrap-3.3.6-dist# ls -la
> total 20
> drwxrwxrwx 5 root root 4096 Jan 12 11:53 .
> drwxr-xr-x 3 root root 4096 Jan 12 11:53 ..
> drwxrwxrwx 2 root root 4096 Jan 12 11:53 css
> drwxrwxrwx 2 root root 4096 Jan 12 11:53 fonts
> drwxrwxrwx 2 root root 4096 Jan 12 11:53 js
>
>
> At bootstrap.css glyphicons are loaded via relative path like:
>
> @font-face {
>   font-family: 'Glyphicons Halflings';
>   src: url('../fonts/glyphicons-halflings-regular.eot');
> ..
>
> Can it be the problem? Or I need to add something in nginx domain config? 
> Or it's bug of hypnotoad?
> The difference between production instance and development localhost only 
> that on localhost I'm using morbo and on production server I use 
> hypnotoad+nginx.
> If I run my project under morbo on production server it also works fine.
>
> I'm using Mojolicious v. 6.11
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] How to use Mojo::IOLoop timer at helpers?

2016-01-22 Thread Pavel Serikov
I need to send one request, then wait 10 seconds, then send another 
request, then render result.
Assume that I need to use Mojo::IOLoop for that (please correct me if there 
are other options).

If I do it inside route everything works fine:
get '/a' => sub {
  my $self = shift;
  my $req1 = $self->ua->post(...)->res;
  Mojo::IOLoop->timer(10 => sub {
 my $req2 = $self->ua->get('...'.$req1)->res;
$self->render(json => $req2);
  });
};

 But if move this code to helper it doesn't work, Mojo render result 
immediately.
helper a_proxy => sub {
  my ($self, $params) = @_;
  my $delay = Mojo::IOLoop->delay(
sub {
  my $delay = shift;
  my $req1 = $self->ua->post('...' => $delay->begin);
},
sub {
  my ($delay, $tx) = @_;
  $delay->data({id => $tx->res});
  Mojo::IOLoop->timer(10 => $delay->begin);
},
sub {
  my $delay = shift;
  my $req2 = $self->ua->get('...'.$delay->data->{id})->res;
  return $req2;
}
  );
};

..

get '/a' => sub {
  my $self = shift;
  my $r = $self->a_proxy( { ... } );
  $self->render(json => $r);
};

What am I doing wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Problem in render via command line ("Mojo::IOLoop already running" error)

2016-02-04 Thread Pavel Serikov
Having route like this in my code:

get '/json_url' => sub {
  my $self = shift;
  my $res = $self->ua->get($api_url => form => \%hash)->res;
  $self->render(json => $res );
};

But when I try to get json via command line and grab it to file I got a 500 
Error:

pavel@pavel-VBox-Lubuntu:~/projects/...$ ./myapp.pl get /json_url
[Thu Feb  4 14:29:15 2016] [debug] GET "/json_url"
[Thu Feb  4 14:29:15 2016] [debug] Routing to a callback
[Thu Feb  4 14:29:15 2016] [error] Mojo::IOLoop already running at /usr/
local/share/perl/5.18.2/Mojo/UserAgent.pm line 60.
[Thu Feb  4 14:29:15 2016] [debug] Template "exception.development.html.ep" 
not found
[Thu Feb  4 14:29:15 2016] [debug] Template "exception.html.ep" not found
[Thu Feb  4 14:29:15 2016] [debug] Rendering template "mojo/debug.html.ep"
[Thu Feb  4 14:29:15 2016] [debug] Rendering template "mojo/menubar.html.ep"
[Thu Feb  4 14:29:15 2016] [debug] Your secret passphrase needs to be 
changed
[Thu Feb  4 14:29:15 2016] [debug] 500 Internal Server Error (0.086742s, 
11.528/s)


Same way with rendering html templates. 

I noticed that problem only happens if I make in a route code request to 
external API via Mojolicious::UserAgent 
. Simple json/html rendering like 
this:

get '/json_test' => sub {
  my $self = shift;
  $self->render(json => "ok");
};

pavel@pavel-VBox-Lubuntu:~/projects/...$ ./myapp.pl get /json_test
[Thu Feb  4 14:41:01 2016] [debug] Reading configuration file 
"/home/pavel/projects/kayako-scoreboard/myapp.conf"
[Thu Feb  4 14:41:01 2016] [debug] GET "/json_test"
[Thu Feb  4 14:41:01 2016] [debug] Routing to a callback
[Thu Feb  4 14:41:01 2016] [debug] 200 OK (0.001050s, 952.381/s)
"ok"

 works fine.

I'm using latest Mojolicious version, 6.43.

Have no idea why described problem happens, please help me. Do I need to 
format routes to non-blocking if I need to use them via command line?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] How to use production.log under command line ?

2016-03-23 Thread Pavel Serikov
I'm calling one of route of my Mojolicious::Lite app via cron, using 
command-line 
interface , like this:

*/5 * * * * perl /home/lab/MyApp get /update?filter=opened

inside MyApp there is some logging strings like

app->log->info('Variable a:'.$a);

But as I noticed that app is not writing to production.log or debug.log 
when accessed via command line.

How to call same (as access to routes via browser) logging when access the 
app via command line?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: How to use production.log under command line ?

2016-03-24 Thread Pavel Serikov
Great, thank you for tip. It works perfectly :)

среда, 23 марта 2016 г., 17:10:59 UTC+3 пользователь Jan Henning Thorsen 
написал:
>
> Oh! I missed out on "debug.log" as well. Could it be wrong file 
> permissions? There's a lot that can go wrong when running from "cron".
>
> I normally add "1>/tmp/cron-app-tmp.log 2>&1" when I can't figure out what 
> is going on.
>
>
> On Wednesday, March 23, 2016 at 3:07:20 PM UTC+1, Jan Henning Thorsen 
> wrote:
>>
>> Have you tried "perl /home/lab/MyApp get -m production 
>> /update?filter=opened" ?
>>
>> For more information: mojo get --help
>>
>>
>>
>> On Wednesday, March 23, 2016 at 12:09:37 PM UTC+1, Pavel Serikov wrote:
>>>
>>> I'm calling one of route of my Mojolicious::Lite app via cron, using 
>>> command-line 
>>> interface <https://metacpan.org/pod/Mojolicious::Commands>, like this:
>>>
>>> */5 * * * * perl /home/lab/MyApp get /update?filter=opened
>>>
>>> inside MyApp there is some logging strings like
>>>
>>> app->log->info('Variable a:'.$a);
>>>
>>> But as I noticed that app is not writing to production.log or debug.log 
>>> when accessed via command line.
>>>
>>> How to call same (as access to routes via browser) logging when access 
>>> the app via command line?
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Using into Mojolicious app code that will never exit - how to?

2016-03-24 Thread Pavel Serikov
I want to output my log via websocket using File::Tail.

Below is my code:

use Mojolicious::Lite;
use Mojo::EventEmitter;
use File::Tail;

helper events => sub { state $events = Mojo::EventEmitter->new };

get '/' => 'log';

websocket '/ws' => sub {
  my $c = shift;
  app->log->info(sprintf 'Client connected: %s', $c->tx);
  $c->inactivity_timeout(3600);
  my $file = File::Tail->new(name => '/home/pavel/test.txt', maxinterval => 
1, adjustafter => 7);
  while (defined(my $line=$file->read)) {
$c->send({json => $line});
  }
};

app->start;

__DATA__

@@ log.html.ep


  var ws  = new WebSocket('<%= url_for('ws')->to_abs %>');
  ws.onmessage = function (e) {
document.getElementById('log').innerHTML += '

' + e.data + '

'; }; function sendChat(input) { ws.send(input.value); input.value = '' } When I do *echo "test" >> /home/pavel/test.txt* Nothing happened, "test" message isn't showing on webpage. Moreover I can't refresh the page. I don't know why but I think that it's because ofwhile (defined(my $line=$file->read)) { act like an infinite loop and can't properly interact with non-blocking mojolicious nature. How to make app working? -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+unsubscr...@googlegroups.com. To post to this group, send email to mojolicious@googlegroups.com. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.

[Mojolicious] Best way to serve README.md

2016-03-28 Thread Pavel Serikov
I want that my README.md will be available under */**readme* route. How to 
do that?

I checked the docs 

 
about ways of serving static files, but problem that I need to process 
markdown to html firstly. It's possible to do with Text::Markdown 
 or other plugins, but how to use 
it together with reply->static 
 
helper? 
Or maybe there is ready-to-use plugin? I found 
Mojolicious::Plugin::Directory 
, but seems like 
it serve all static files, but I need to serve only one.

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Convert code to non-blocking

2016-04-05 Thread Pavel Serikov
I want to make non-blocking requests to API via Mojo::UserAgent and allow 
to render result of request without waiting result of previous request.
Code of working with API made in separate module (listing below). How to 
convert code to non-blocking way?

*$cat Test.pm*
...
my $ua = Mojo::UserAgent->new;
sub api_func1 {
return $ua->get($api_url => form => \%hash)->res->body;
} 
...
*$cat myapp.pl*
...
get '/r' => sub {
my $c = shift;
$c->render(json => api_func1());
}
...

I rewrote it to non-blocking way:

*$cat Test.pm*
sub api_func1 {
my $cb = shift;
$ua->get($api_url => form => \%hash => sub {
my ($ua, $tx) = @_;
*$cb**($tx->res->json);*
  });
Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
};
*$cat myapp.pl*
get '/r' => sub {
my $c = shift;
api_func1(sub => {
 my ($self, $json) = @_;
 $c->render(json => $json);
})

But I got a syntax error at string marked orange. What is wrong?


-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Convert code to non-blocking

2016-04-05 Thread Pavel Serikov
I misprinted, at blocking Test.pm there is 

return $ua->get($api_url => form => \%hash)->res->*json*

But it doesn't affect on problem.

вторник, 5 апреля 2016 г., 19:14:37 UTC+4 пользователь Pavel Serikov 
написал:
>
> I want to make non-blocking requests to API via Mojo::UserAgent and allow 
> to render result of request without waiting result of previous request.
> Code of working with API made in separate module (listing below). How to 
> convert code to non-blocking way?
>
> *$cat Test.pm*
> ...
> my $ua = Mojo::UserAgent->new;
> sub api_func1 {
> return $ua->get($api_url => form => \%hash)->res->body;
> } 
> ...
> *$cat myapp.pl <http://myapp.pl>*
> ...
> get '/r' => sub {
> my $c = shift;
> $c->render(json => api_func1());
> }
> ...
>
> I rewrote it to non-blocking way:
>
> *$cat Test.pm*
> sub api_func1 {
> my $cb = shift;
> $ua->get($api_url => form => \%hash => sub {
> my ($ua, $tx) = @_;
> *$cb**($tx->res->json);*
>   });
> Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
> };
> *$cat myapp.pl <http://myapp.pl>*
> get '/r' => sub {
> my $c = shift;
> api_func1(sub => {
>  my ($self, $json) = @_;
>  $c->render(json => $json);
> })
>
> But I got a syntax error at string marked orange. What is wrong?
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Convert code to non-blocking

2016-04-05 Thread Pavel Serikov
Thanks, Dominique, I was inattentive. But problem still not solved. Not I 
have an error

Global symbol "$json" requires explicit package name


at string marked yellow.

api_func1(sub => {
 my ($self, $json) = @_;
 $c->render(json => $json);
})

What could be wrong?

Also tried 

api_func1(sub => {
 *my $json = shift;*
 $c->render(json => $json);
})

But same error.




вторник, 5 апреля 2016 г., 19:19:47 UTC+4 пользователь Dominique Dumont 
написал:
>
> On Tuesday 05 April 2016 08:14:36 Pavel Serikov wrote: 
> > But I got a syntax error at string marked orange. What is wrong? 
>
> $cb is a sub reference and must be called with '->': 
>
>  $cb->($tx->res->json); 
>
> HTH 
>
> -- 
>  https://github.com/dod38fr/   -o- http://search.cpan.org/~ddumont/ 
> http://ddumont.wordpress.com/  -o-   irc: dod at irc.debian.org 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Convert code to non-blocking

2016-04-07 Thread Pavel Serikov
Hi David,

Yes, an anonymous function.
Tried as you suggested (without '=>') but still getting an error:

Mojo::Reactor::Poll: I/O watcher failed: Can't use an undefined value as a 
subroutine reference at $cb->($tx->res->body)

Can you guide me what's wrong now?


вторник, 5 апреля 2016 г., 19:46:33 UTC+4 пользователь David Stevenson 
написал:
>
> What are you trying to pass to api_func1?  An anonymous function?
>
> So did you mean api_func1(sub{…})
>
> as opposed to
>
> api_func1(sub =>{…});  # Extra => ?
>
>
> On 5 Apr 2016, at 16:39, Pavel Serikov > 
> wrote:
>
> Thanks, Dominique, I was inattentive. But problem still not solved. Not I 
> have an error
>
> Global symbol "$json" requires explicit package name
>
>
> at string marked yellow.
>
> api_func1(sub => {
>  my ($self, $json) = @_;
>  $c->render(json => $json);
> })
>
> What could be wrong?
>
> Also tried 
>
> api_func1(sub => {
>  *my $json = shift;*
>  $c->render(json => $json);
> })
>
> But same error.
>
>
>
>
> вторник, 5 апреля 2016 г., 19:19:47 UTC+4 пользователь Dominique Dumont 
> написал:
>>
>> On Tuesday 05 April 2016 08:14:36 Pavel Serikov wrote: 
>> > But I got a syntax error at string marked orange. What is wrong? 
>>
>> $cb is a sub reference and must be called with '->': 
>>
>>  $cb->($tx->res->json); 
>>
>> HTH 
>>
>> -- 
>>  https://github.com/dod38fr/   -o- http://search.cpan.org/~ddumont/ 
>> http://ddumont.wordpress.com/  -o-   irc: dod at irc.debian.org 
>>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to mojolicious...@googlegroups.com .
> To post to this group, send email to mojol...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Mojolicious::Plugin::I18N usage

2016-06-17 Thread Pavel Serikov
Hi all,

I made one-file Mojolicious app (*test.pl*) to test 
Mojolicious::Plugin::I18N, but test fails.

package main;
use Mojo::Base -strict;
use Test::More;
use Test::Mojo;


{
package MyApp::Controller::Test;
use Mojo::Base 'Mojolicious::Controller';
sub info {
  my $self = shift;
  $self->render(json => { msg => $self->l('hello')} );
}

   package MyApp::I18N::ru;
   use Mojo::Base 'MyApp::I18N';
   our %Lexicon = (hello => 'Privet');
   1;

   package MyApp;
   use Mojo::Base 'Mojolicious';
   sub startup {
 my $self = shift;
 $self->plugin('I18N');
 $self->routes->get('/info')->to('test#info');
   }

}

my $app = MyApp::->new();
my $t = Test::Mojo->new($app);
$t->get_ok('/info/ru')->status_is(200)->json_is({msg => 'hallo'});
done_testing;

error that I got:

perl test.pl 
> Can't locate MyApp/I18N.pm in @INC (you may need to install the 
> MyApp::I18N module)


What can be wrong? 

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Mojolicious::Plugin::I18N usage

2016-06-21 Thread Pavel Serikov
Hi Stefan,

Thank you for answer. According source code 
<https://github.com/sharifulin/mojolicious-plugin-i18n/blob/master/lib/Mojolicious/Plugin/I18N.pm#L16>
 
MyApp::I18N must be defined when I register the plugin:

$self->plugin('I18N');

I (and not only me <https://rt.cpan.org/Public/Bug/Display.html?id=104650>) 
think that the plugin doesn't work in current Mojolicious version - tested 
it at 6.55 and 6.66. I'm trying to understand the reason and it will be 
great if you will help me.
 
For example, when I have 
%=l 'about_service'
at my template and localization module looks like

package MyApp::I18N::en;
use Mojo::Base 'MyApp::I18N';
require Exporter;
our @ISA = qw(Exporter);
our %Lexicon = (
about_service => 'About app',
);
1;

at rendered template I still see *'about_service'* text instead of 

*'About app'*I also tried to specify the url, e.g. /en. At log I see debug 
message

[Tue Jun 21 11:02:41 2016] [debug] Found language en in URL /en
[Tue Jun 21 11:02:41 2016] [debug] GET "/"
[Tue Jun 21 11:02:41 2016] [debug] Routing to a callback
[Tue Jun 21 11:02:41 2016] [debug] Rendering cached template "index.html.ep"
[Tue Jun 21 11:02:41 2016] [debug] Rendering cached template 
"layouts/default.html.ep"
[Tue Jun 21 11:02:41 2016] [debug] 200 OK (0.007188s, 139.121/s)

But localize subroutine still doesn't work.

What could be the problem?


понедельник, 20 июня 2016 г., 21:43:25 UTC+3 пользователь Stefan Adams 
написал:
>
>
> On Fri, Jun 17, 2016 at 3:48 AM, Pavel Serikov  > wrote:
>
>>package MyApp::I18N::ru;
>>use Mojo::Base 'MyApp::I18N';
>
>
> Can't locate MyApp/I18N.pm in @INC (you may need to install the 
>> MyApp::I18N module)
>
>
> You are subclassing MyApp::I18N into MyApp::I18N::ru, but I do not see a 
> package MyApp::I18N defined in your code.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Mojolicious::Plugin::I18N usage

2016-06-22 Thread Pavel Serikov
Problem solved :)
I just forgot to put I18N folder at MyApp folder at root of project.

вторник, 21 июня 2016 г., 11:05:36 UTC+3 пользователь Pavel Serikov написал:
>
> Hi Stefan,
>
> Thank you for answer. According source code 
> <https://github.com/sharifulin/mojolicious-plugin-i18n/blob/master/lib/Mojolicious/Plugin/I18N.pm#L16>
>  
> MyApp::I18N must be defined when I register the plugin:
>
> $self->plugin('I18N');
>
> I (and not only me <https://rt.cpan.org/Public/Bug/Display.html?id=104650>) 
> think that the plugin doesn't work in current Mojolicious version - tested 
> it at 6.55 and 6.66. I'm trying to understand the reason and it will be 
> great if you will help me.
>  
> For example, when I have 
> %=l 'about_service'
> at my template and localization module looks like
>
> package MyApp::I18N::en;
> use Mojo::Base 'MyApp::I18N';
> require Exporter;
> our @ISA = qw(Exporter);
> our %Lexicon = (
> about_service => 'About app',
> );
> 1;
>
> at rendered template I still see *'about_service'* text instead of 
>
> *'About app'*I also tried to specify the url, e.g. /en. At log I see 
> debug message
>
> [Tue Jun 21 11:02:41 2016] [debug] Found language en in URL /en
> [Tue Jun 21 11:02:41 2016] [debug] GET "/"
> [Tue Jun 21 11:02:41 2016] [debug] Routing to a callback
> [Tue Jun 21 11:02:41 2016] [debug] Rendering cached template 
> "index.html.ep"
> [Tue Jun 21 11:02:41 2016] [debug] Rendering cached template 
> "layouts/default.html.ep"
> [Tue Jun 21 11:02:41 2016] [debug] 200 OK (0.007188s, 139.121/s)
>
> But localize subroutine still doesn't work.
>
> What could be the problem?
>
>
> понедельник, 20 июня 2016 г., 21:43:25 UTC+3 пользователь Stefan Adams 
> написал:
>>
>>
>> On Fri, Jun 17, 2016 at 3:48 AM, Pavel Serikov  
>> wrote:
>>
>>>package MyApp::I18N::ru;
>>>use Mojo::Base 'MyApp::I18N';
>>
>>
>> Can't locate MyApp/I18N.pm in @INC (you may need to install the 
>>> MyApp::I18N module)
>>
>>
>> You are subclassing MyApp::I18N into MyApp::I18N::ru, but I do not see a 
>> package MyApp::I18N defined in your code.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Best way to automatically generate documentation for Mojolicious helpers

2016-07-22 Thread Pavel Serikov
Usually I use autopod 
 for 
auto-generation of documentation for perl modules. But it doesn't work for 
Mojolicious helpers, autopod simply doesn't see them. 
Is there any ready-to-use solution? (Mojolicious::Plugin::... or anything 
else)


-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Remove unwanted output

2016-11-11 Thread Pavel Serikov
Hello everyone,

I have a simple perl script *runserver.pl *which runs mojo application from 
class :

#!/usr/bin/env perl
use Mojolicious::Commands;
use Net::EmptyPort qw(empty_port);
my $port = empty_port(3000);
Mojolicious::Commands->start_app('API::Google::Server', 'daemon', '-l', 
'http://*:'.$port);

When I run it it produces too much additional log (= showing *mojo help*) 
like I run Mojolicious app from shell without any parameters:

pavel@pavel-Inspiron-3542:~/projects/google-apis-perl$ perl runserver.pl 
Usage: APPLICATION COMMAND [OPTIONS]

  mojo version
  mojo generate lite_app
  ./myapp.pl daemon -m production -l http://*:8080
  ./myapp.pl get /foo
  ./myapp.pl routes -v

Tip: CGI and PSGI environments can be automatically detected very often and
 work without commands.

Options (for all commands):
  -h, --help  Get more information on a specific command
  --homePath to home directory of your application, defaults 
to
  the value of MOJO_HOME or auto-detection
  -m, --modeOperating mode for your application, defaults to the
  value of MOJO_MODE/PLACK_ENV or "development"

Commands:
 cgi   Start application with CGI
 cpanify   Upload distribution to CPAN
 daemonStart application with HTTP and WebSocket server
 eval  Run code against application
 generate  Generate files and directories from templates
 get   Perform HTTP request
 inflate   Inflate embedded files to real files
 prefork   Start application with pre-forking HTTP and WebSocket server
 psgi  Start application with PSGI
 routesShow available routes
 test  Run tests
 version   Show versions of available modules

See 'APPLICATION help COMMAND' for more information on a specific command.
[Sat Nov 12 00:18:04 2016] [info] Listening at "http://*:3005";
Server available at http://127.0.0.1:3005

I need that log will be just 

[Sat Nov 12 00:18:04 2016] [info] Listening at "http://*:3005";
Server available at http://127.0.0.1:3005

How to remove additional output ?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Is there any way to execute helper outside the route?

2017-01-28 Thread Pavel Serikov
It's better to explain the problem on example. I'm writing bot for Telegram 
and want to implement getting updates via WebHook and polling (via Mojo::
IOLoop) both.

helper answer => sub {
 my ($c, $update) = shift;
 ...
 if ($update->{message}{text} eq "something") {
   $api->sendMessage ({ chat_id => $chat_id, text => '/shot - Get online 
camera shot' });
 }
};

...

post '/'.$config->{telegram_api_token} => sub {
  my $c = shift;
  my $update = $c->req->json;
  $c->answer($update);
  $c->render(json => "ok");
};

if ($config->{polling}) {
 $api->deleteWebhook();

 Mojo::IOLoop->recurring($config->{polling_timeout} => sub {
   my $updates = $api->getUpdates;
   my @updates = @{$updates->{result}};

   for my $u (@updates) {
 app->controller_class->helpers->answer($u); # How to call helper 
answer here ?
   }
 });

}

Is there any way to execute helper 'answer' outside the routes or I need to 
move project from Mojolicious::Lite to Mojolicious ?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Is there any way to customize hypnotoad listen port NOT from external config file ?

2017-02-16 Thread Pavel Serikov
I'm writing a script which will manage ports of my mojo apps. 

E.g. I want to manage server.pl app:

my $hypnotoad = Mojo::Server::Hypnotoad->new;
$hypnotoad->configure('server.conf');
$hypnotoad->run('server.pl');

If I need to specify port other than 8080 - I need to setup it in 
*server.conf* like

{
  hypnotoad => {
listen  => ['http://*:8093'],
  }
};

Is there any way to setup it directly, without external config file ?

I found that Mojo::Server::Hypnotoad has listen 

 
attribute but it seems doesn't work or I'm using it wrong way:

my $hypnotoad = Mojo::Server::Hypnotoad->new;
$hypnotoad->listen(['https://127.0.0.1:8093']);
$hypnotoad->run('server.pl');

I'm getting 
Can't locate object method "listen" via package "Mojo::Server::Hypnotoad"
error

Any suggestions appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Problem with implementing custom command in Mojolicious::Lite app

2017-03-10 Thread Pavel Serikov
Hello everyone,

I'm trying to implement custom command 

 
in my app  like described in cookbook 

.

Custom namespace is loaded, however command doesn't work:

pavel@pavel-Inspiron-3542:/projects/bom$ socialbom cmd1
Unknown command "cmd1", maybe you need to install it?
Compilation failed in require at /usr/local/bin/socialbom line 14,  
line 1.

What am I doing wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Problem with implementing custom command in Mojolicious::Lite app

2017-03-10 Thread Pavel Serikov
You are absolutely right, it's mine inattention :)
Question closed.

пятница, 10 марта 2017 г., 15:03:06 UTC+3 пользователь Luc Didry написал:
>
> vendredi 10 mars 2017, 03:48:27 CET Pavel Serikov wrote: 
> > Hello everyone, 
> > 
> > I'm trying to implement custom command 
> > <
> https://github.com/pavelsr/SocialBOM/blob/master/lib/App/SocialBOM/Command/cmd1.pm>
>  
>
> > in my app <https://github.com/pavelsr/socialbom> like described in 
> cookbook 
> > <
> http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Adding-commands-to-Mojolicious>
>  
>
> > . 
> > 
> > Custom namespace is loaded, however command doesn't work: 
> > 
> > pavel@pavel-Inspiron-3542:/projects/bom$ socialbom cmd1 
> > Unknown command "cmd1", maybe you need to install it? 
> > Compilation failed in require at /usr/local/bin/socialbom line 14, 
>  
> > line 1. 
> > 
> > What am I doing wrong? 
> > 
> > 
>
> Just a guess : in 
> https://github.com/pavelsr/SocialBOM/blob/master/lib/App/SocialBOM.pm#L197, 
> you 
> should put 
> push @{app->commands->namespaces}, 'App::SocialBOM::Command'; 
> instead of 
> push @{app->commands->namespaces}, 'App::SocialBOM::Command::cmd1'; 
> -- 
> Luc 
> https://fiat-tux.fr/ 
> https://luc.frama.io/ 
> Internet n'est pas compliqué, Internet est ce que vous en faites. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Looking for particular Mojolicious method

2017-03-13 Thread Pavel Serikov
Usually I'm releasing my Mojo apps as packages, e.g. *App::MojoApp*.
Also I'm creating a *mojoapp* CLI tool (like this 
) which does 
Mojolicious::Commands->start_app(App::MojoApp*)* for easy running app from 
any place.

Would like to implement a custom command 

 
which running my app on hypnotoad production server.
Since Mojo::Server::Hypnotoad 
 can't load application 
from class, as Mojolicious::Commands::start_app() 
 do, I need to 
impement finding a path to main mojo app module by myself.

Now it looks like
package App::MojoApp::Command::hypno;

use Mojo::Base 'Mojolicious::Command';
use Mojo::Server::Hypnotoad;

has description => 'Run app on hypnotoad production server';
has usage   => "Usage: APPLICATION hypno";

sub run {
  my ($self, @args) = @_;
  my $p = __PACKAGE__;
  my @s = split(/::/, $p);
  $p = join('::', $s[0], $s[1]);
  $p =~ s/::/\//g;
  $p =~ s/$/.pm/;
  my $hypnotoad = Mojo::Server::Hypnotoad->new;
  $hypnotoad->run($INC{$p});
}

1;

Is there any way built-in method to get an installation location of main 
mojo module ?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Looking for particular Mojolicious method

2017-03-13 Thread Pavel Serikov
Hi Sebastian,

Thanks for a quick feedback.

Could you please explain more why it's a bad idea to implement hypnotoad 
and morbo commands ?
And what is the recommendation in my case, do not release mojolicious apps 
as packages, right ?

понедельник, 13 марта 2017 г., 15:33:21 UTC+3 пользователь sri написал:
>
> Don't do this, if there was a good way to have hypnotoad and morbo 
> commands we would already have hypnotoad and morbo commands.
>
> --
> sebastian
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Can attributes of Mojo::Base -based class be changed inside this class ? (got Can't modify non-lvalue subroutine call error)

2017-04-05 Thread Pavel Serikov
Better to explain the problem by code :)

Just a small annotation: I'm writing a wrapper under Config:: 
JSON 
 module. When calling ->new 
constructor of Config::JSON it's required to pass obligatory parameter, 
pathToFile So it's not possible to construct wrapper via Mojo::Base 
attribute  or Mojo::Base::new 
basic constructor  because 
pathToFile is user-defined. 
I decided to make a custom constructor setup() function. But this function 
doesn't work if I try to change attribute inside it.

This code doesn't work:

package ConfigJSON;
use Mojo::Base -base;
use Config::JSON;

has 'pathToTokensFile' => 'config.json'; # default is config.json
has 'tokensfile'; # pathToTokensFile wrapped by Config::JSON

sub setup {
  my $self = shift;
  $self->tokensfile = Config::JSON->new(pathToFile => $self->
pathToTokensFile); # this string cause Can't modify non-lvalue subroutine 
call error
};



package main;
use Data::Dumper;
my $c = ConfigJSON->new;
$c->pathToTokensFile('gapi.conf');
$c->setup();
warn Dumper $c;


This code works:

package ConfigJSON;
use Mojo::Base -base;
use Config::JSON;

has 'pathToTokensFile' => 'config.json'; # default is config.json
my $tokensfile;

sub setup {
  my $self = shift;
  $tokensfile = Config::JSON->new(pathToFile => $self->pathToTokensFile);
};



package main;
use Data::Dumper;
my $c = ConfigJSON->new;
$c->pathToTokensFile('gapi.conf');
$c->setup();
warn Dumper $c;


Why first example doesn't work?
I'd like to save ability to call ConfigJSON->tokensfile from another module.

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Can attributes of Mojo::Base -based class be changed inside this class ? (got Can't modify non-lvalue subroutine call error)

2017-04-05 Thread Pavel Serikov
Many thanks, Stefan, it works!

среда, 5 апреля 2017 г., 16:29:27 UTC+3 пользователь Stefan Adams написал:
>
>
> On Wed, Apr 5, 2017 at 6:29 AM, Pavel Serikov  > wrote:
>
>> $self->tokensfile = Config::JSON->new(pathToFile => $self->
>> pathToTokensFile); # this string cause Can't modify non-lvalue 
>> subroutine call error
>
>
> You need to set the attribute like this:
>
> $self->tokensfile(Config::JSON->new(pathToFile => $self->pathToTokensFile
> ));
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Inheriting "live" attribute values of parent class with Mojo::Base

2017-04-06 Thread Pavel Serikov
Question in comment to code :)

package Cat;
use Mojo::Base -base;

has 'token' => '12345';
has 'Tiger' => sub { Cat::Tiger-> new };


package Cat::Tiger;
use Mojo::Base 'Cat';


package main;
my $c = Cat->new(token=>'54321');
warn Dumper $c->Tiger->token; # how to make '54321' instead of '12345' ?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Watch change of attribute in Mojo::Base -based class using Scalar::Watcher or any other module

2017-04-09 Thread Pavel Serikov
Hi guys,

Could you please share with me a chunk of code how do you watch attributes 
change?
I found good module, Scalar::Watcher 
, but I can't get it work inside 
a class:

package Cat;
use Mojo::Base -base;
use Scalar::Watcher qw(when_modified);
use feature 'say';

has 'attr1' => 1;
has 'attr2' => 2;

has 'test' => sub { # "fake" attribute for getting access to $self
  my $self = shift;
  when_modified $self->attr1, sub { $self->attr2(3); say "meow" };
};


package main;
use Data::Dumper;

my $me = Cat->new;
$me->attr1;
warn Dumper $me;
say $me->attr1(3)->attr2; # attr2 is still 2, but must be 3

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: modest snippets in templates

2017-04-10 Thread Pavel Serikov
You can include chunks of html code even without perlish variables, same 
way as with variables

http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Partial-templates



понедельник, 10 апреля 2017 г., 1:08:53 UTC+3 пользователь iaw4 написал:
>
>
> dear M experts---I would like to embed predefined snippets of content into 
> my template, which does not require any perl-ish variables.  think
>
> %layout 'mylayout';
> %title 'mypage';
>
> %include 'datatables';
>
>
>
> to facilitate the use of datatables in this particular webpage (some 
> javascript, css, html, etc).  how is this done the M way?
>
> sincerely, /iaw
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Watch change of attribute in Mojo::Base -based class using Scalar::Watcher or any other module

2017-04-10 Thread Pavel Serikov
Already discussed this question on stack
http://stackoverflow.com/questions/43326596/watch-change-of-attribute-inside-perl-class
so now it's closed :)


понедельник, 10 апреля 2017 г., 1:25:07 UTC+3 пользователь Pavel Serikov 
написал:
>
> Hi guys,
>
> Could you please share with me a chunk of code how do you watch attributes 
> change?
> I found good module, Scalar::Watcher 
> <https://metacpan.org/pod/Scalar::Watcher>, but I can't get it work 
> inside a class:
>
> package Cat;
> use Mojo::Base -base;
> use Scalar::Watcher qw(when_modified);
> use feature 'say';
>
> has 'attr1' => 1;
> has 'attr2' => 2;
>
> has 'test' => sub { # "fake" attribute for getting access to $self
>   my $self = shift;
>   when_modified $self->attr1, sub { $self->attr2(3); say "meow" };
> };
>
>
> package main;
> use Data::Dumper;
>
> my $me = Cat->new;
> $me->attr1;
> warn Dumper $me;
> say $me->attr1(3)->attr2; # attr2 is still 2, but must be 3
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: How do you handle Hypnotoad in Docker containers?

2017-05-26 Thread Pavel Serikov
I have a similar issue, but with morbo: web server doesn't watch for 
changes. 
So I'd like to renew discussion about dockerizing mojolicious apps.

Below is my docker-compose.yml file

version: '2'

services:
  web:
image: pavelsr/kayako-dashboard-dev
container_name: kayako-dashboard
volumes:
  - ${PWD}:/root/www/
working_dir: /root/www
command: [ "morbo", "-v", "-w", "dashboard_server.conf", 
"./script/dashboard_server" ]
ports:
  - "3000:3000"
links:
  - db

  db:
image: mongo
container_name: kayako-dashboard-mongodb
ports:
  - "27017:27017"

If I want to check results after updating the source code I need to do 
docker-compose down && docker-compose up each time. It's a little bit 
annoying.
Is there any solution ?


четверг, 29 января 2015 г., 17:10:37 UTC+3 пользователь Alexander Karelas 
написал:
>
> As far as I know, docker containers require their processes to be 
> foreground processes, so that a TERM signal is sent to them gracefully 
> when docker is shutting down (because the host server itself might be 
> shutting down). 
>
> However if I run: 
>
> hypnotoad -f app.pl 
>
> ...then, when I try to do "hot deployment" (by running hypnotoad -f 
> app.pl again), the new hypnotoad process is not a foreground one anymore. 
>
> How do we solve this problem? 
>
> Should I forget about "hot deployment" when working in Docker containers? 
>
> Thanks, 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Re: How do you handle Hypnotoad in Docker containers?

2017-05-26 Thread Pavel Serikov
Thanks for tip about docker-restart.
But is it possible to avoid `docker-compose restart web` at all and watch 
for changes automatically ?
I mount my source code as a volume so there must be a way...


пятница, 26 мая 2017 г., 16:34:14 UTC+3 пользователь zakame написал:
>
> Hi!
>
> On 05/26/2017 09:23 PM, Pavel Serikov wrote:
>
> I have a similar issue, but with morbo: web server doesn't watch for 
> changes. 
> So I'd like to renew discussion about dockerizing mojolicious apps.
>
> Below is my docker-compose.yml file
>
> version: '2'
>
> services:
>   web:
> image: pavelsr/kayako-dashboard-dev
> container_name: kayako-dashboard
> volumes:
>   - ${PWD}:/root/www/
> working_dir: /root/www
> command: [ "morbo", "-v", "-w", "dashboard_server.conf", 
> "./script/dashboard_server" ]
> ports:
>   - "3000:3000"
> links:
>   - db
>
>   db:
> image: mongo
> container_name: kayako-dashboard-mongodb
> ports:
>   - "27017:27017"
>
> If I want to check results after updating the source code I need to do 
> docker-compose down && docker-compose up each time. It's a little bit 
> annoying.
> Is there any solution ?
>
>
> For morbo, you can always pass additional `-w` options, e.g.
>
> morbo -v -w myapp.conf -w lib -w templates -w public ./script/myapp
>
> Also, on the docker-compose side, you can do e.g. `docker-compose restart 
> web` to restart only the web (mojo) service, instead of tearing down the 
> entire environment via docker-compose up/down.
>
>
> Cheers,
>
> Zak
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Re: How do you handle Hypnotoad in Docker containers?

2017-05-26 Thread Pavel Serikov
Oh, sorry, forgot about -w lib.
Now it works, thanks a lot.

пятница, 26 мая 2017 г., 17:08:54 UTC+3 пользователь zakame написал:
>
> On 05/26/2017 10:06 PM, Pavel Serikov wrote: 
> > Thanks for tip about docker-restart. 
> > But is it possible to avoid `docker-compose restart web` at all and 
> > watch for changes automatically ? 
> > I mount my source code as a volume so there must be a way... 
> > 
>
> yep, the aforementioned morbo invocation should work. e.g. in 
> docker-compose.yml 
>
>version: '2' 
>services: 
>  web: 
>command: morbo -v -w myapp.conf -w lib -w templates -w public 
> ./script/myapp 
> 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Understanding interaction between Minion and websocket through events

2018-04-30 Thread Pavel Serikov
Hi there,

I wrote demo app, https://github.com/pavelsr/minion_ws_demo
App must notify user through websocket when minion job is finished.

But it doesn't work as expected.

Could someone help to figure out what is wrong? You can write a review 
directly in commit 

 
for convenience.

In general, there are two corresponding problems:

1) Web socket doesn't react on 
$self->on(task_finished => sub {  
but I see in debug log last message of task code: 
$job->app->log->debug('Test minion task '.$job->task.'(id='.$job->id.') 
finished');

2) Minion Admin UI 
 shows that 
task is unactive, but according debug log all task code was executed (I see 
output from last task code string).

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Understanding interaction between Minion and websocket through events

2018-05-02 Thread Pavel Serikov
Figured out what was the issue.
When you have workers running, any new task is automatically performed.

So it's enough to add task like $self->minion->enqueue('some_task') and run 
at least one worker (in my case I run separate docker container).
After that any new task will started automatically.


понедельник, 30 апреля 2018 г., 14:49:32 UTC+3 пользователь Pavel Serikov 
написал:
>
> Hi there,
>
> I wrote demo app, https://github.com/pavelsr/minion_ws_demo
> App must notify user through websocket when minion job is finished.
>
> But it doesn't work as expected.
>
> Could someone help to figure out what is wrong? You can write a review 
> directly in commit 
> <https://github.com/pavelsr/minion_ws_demo/commit/cf0b5db2108b980ae3aa2b89fc12f075ea6f8ae5#diff-5bff693a803572bca10b2c7357fa7d6eR29>
>  
> for convenience.
>
> In general, there are two corresponding problems:
>
> 1) Web socket doesn't react on 
> $self->on(task_finished => sub {  
> but I see in debug log last message of task code: 
> $job->app->log->debug('Test minion task '.$job->task.'(id='.$job->id.') 
> finished');
>
> 2) Minion Admin UI 
> <https://metacpan.org/pod/Mojolicious::Plugin::Minion::Admin> shows that 
> task is unactive, but according debug log all task code was executed (I see 
> output from last task code string).
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Undefined address for Socket::pack_sockaddr_in

2019-12-10 Thread Pavel Serikov
I got a strange error when make GET request to Mojo server using curl:

Undefined address for Socket::pack_sockaddr_in at 
> /usr/lib/perl5/core_perl/Socket.pm line 851.
>

Same error I got when running server under morbo and under daemon mode.

What's wrong?

Notice: mojo server is running in docker container.

Mojolicious version : 8.27

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mojolicious/822482f8-d186-41a8-948a-98925cc2b68c%40googlegroups.com.


Re: [Mojolicious] Undefined address for Socket::pack_sockaddr_in

2019-12-11 Thread Pavel Serikov
I'm running server with command  *morbo -w lib -w public -w api_conf.yaml 
api.pl  *(same problem when running like *perl api.pl daemon* )

*api.pl* is Mojolicious::Lite app.

Make curl request like *curl http://app:3000/api/health*

And full server log on error is 

[2019-12-11 21:55:37.48968] [10] [debug] [4a9def6b] GET "/api/health"
[2019-12-11 21:55:37.49033] [10] [debug] [4a9def6b] Routing to a callback
[2019-12-11 21:55:42.49534] [10] [error] [4a9def6b] Undefined address for 
Socket::pack_sockaddr_in at /usr/lib/perl5/core_perl/Socket.pm line 851.

[2019-12-11 21:55:42.49628] [10] [debug] [4a9def6b] Template 
"exception.development.html.ep" not found
[2019-12-11 21:55:42.49686] [10] [debug] [4a9def6b] Template 
"exception.html.ep" not found
[2019-12-11 21:55:42.49724] [10] [debug] [4a9def6b] Rendering cached 
template "mojo/debug.html.ep"
[2019-12-11 21:55:42.50432] [10] [debug] [4a9def6b] 500 Internal Server 
Error (5.01467s, 0.199/s)

route looks like:

get '/api/health' => sub {
my $c = shift;
my $result = {};
$result->{memcached} = ( defined $c->memcached->stats->{hosts} ) ? 1 : 0
;
$result->{selenoid} = eval { if ( $c->selenium_driver ) { return $c->
selenium_driver->status } };
$result->{telegram} =  eval { app->telegram->getMe->{result}{username} 
};
$c->res->headers->access_control_allow_origin('*');
$c->render( json => $result );
};



среда, 11 декабря 2019 г., 1:26:09 UTC+3 пользователь Veesh Goldman написал:
>
> can you show the command you used to start the server?
>
> On Wed, Dec 11, 2019 at 12:08 AM Pavel Serikov  > wrote:
>
>> I got a strange error when make GET request to Mojo server using curl:
>>
>> Undefined address for Socket::pack_sockaddr_in at 
>>> /usr/lib/perl5/core_perl/Socket.pm line 851.
>>>
>>
>> Same error I got when running server under morbo and under daemon mode.
>>
>> What's wrong?
>>
>> Notice: mojo server is running in docker container.
>>
>> Mojolicious version : 8.27
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Mojolicious" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to mojol...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/mojolicious/822482f8-d186-41a8-948a-98925cc2b68c%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/mojolicious/822482f8-d186-41a8-948a-98925cc2b68c%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mojolicious/07774abe-b66b-4d77-9f6d-57a732701d24%40googlegroups.com.


[Mojolicious] Is it possible to make Mojolicious::Plugin::DefaultHelpers::redirect_to method act same as nginx proxy_pass module?

2022-02-07 Thread Pavel Serikov
I need to redirect requests to particular IP address depending on requested 
url.

E.g. 
example.com/foo -> 172.22.0.6:80
example.com/bar -> 172.22.0.7:80
etc.

Is it possible with Mojolicious out-of-the-box?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mojolicious/1d5193e0-c1a0-4989-bdc4-282245d7626an%40googlegroups.com.