[Mojolicious] Re: struggling with OAuth(2) from google

2019-04-16 Thread Jan Henning Thorsen
Have you tried https://metacpan.org/pod/Mojolicious::Plugin::OAuth2 ?


On Tuesday, April 16, 2019 at 7:48:41 AM UTC+7, iwe...@g.ucla.edu wrote:
>
>
> dear M experts.  I am again struggling with the OAuth module.  this is 
> perhaps because I installed a new ubuntu 18.04.2 machine, and then updated 
> Mojolicious to the current version.
>
> first, for anyone else struggling, Mojolicious::Plugin::Web::Auth depends 
> on Net::SSLeay, which fails installing.  I believe I fixed this by 
> installing `apt install libssl-dev libz-dev`.  I know this is not M's 
> fault, but I would suggest that the Auth author stop the install with a 
> good instructive error message when these two libraries are not detected.  
> grrr
>
>
> second, my M code is still the same as before, but now it is dying with a 
> non-informative error message at the point where I had hoped to get my 
> Google authentication callback:
>
> *Can't locate object method "headers" via package "1" (perhaps you forgot 
> to load "1"?) at 
> /usr/local/share/perl/5.26.1/Mojolicious/Plugin/Web/Auth/OAuth2.pm line 
> 122.*
>
> I believe the callback I am getting from google is:
>
> *http://auth.syllabus.space/auth/google/callback?state=hashcode=hashcode=email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+openid=0=g.ucla.edu_state=hashcodes=none
>  
> *
>
> I am guessing that google encodes the email address in one of the hash 
> codes (which I have blanked here).
>
> my relevant (I think) code excerpt that should be called is
>
> package SylSpace::Controller::AuthAuthenticator;
> use Mojolicious::Lite;
>
> sub google {
>   my ( $self, $access_token, $userinfo ) = @_;
>   my $name = $userinfo->{displayName} || $userinfo->{name};
>   my $email= $userinfo->{email};
>
>   (defined($email)) or die "no good email.";
>
>   return logandreturn( $self, $email, $name, 'google' );
> }
>
> looking at the code, the error comes from
>
> (my $res = $tx->result->is_success ) or do {
> return $callback->{on_error}->( $tx->res->body );
> };
>
> my $dat = $self->_response_to_hash($res);
>
> ...
>
> my $exts = $types->detect( $res->headers->content_type );
>
> could someone please help me?  what could have gone wrong here?
>
>
>

-- 
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: Nordic Perl Workshop and Mojoconf in Oslo

2018-08-09 Thread Jan Henning Thorsen
We have posted the schedule for the conference now! Check it out on 
http://npw2018.oslo.pm/npw2018/schedule

You can still get your ticket at http://oslo.pm/npw2018/tickets if you 
haven't already gotten one.

Looking forward to seeing you in Oslo next month.


On Tuesday, May 8, 2018 at 9:15:49 AM UTC+2, Jan Henning Thorsen wrote:
>
> Nordic Perl Workshop 2018 will be held in Oslo, 6 - 7 September, 2018.
>
> The conference topic is “Perl in the cloud”, with focus on web 
> development, and deployment methods. We are pleased to announce that we 
> will have members from the Mojolicious core team attending and a track 
> dedicated to the Mojolicious real-time web framework.
>
> * You can get information about tickets here: 
> http://oslo.pm/npw2018/tickets
> * And submit your talk here: http://oslo.pm/npw2018/
> * Follow the hashtag #mojoconf and/or #npw2018 on Twitter for updates. 
> https://twitter.com/marcusramberg/status/993750724608774144
>
>
> See you later this year!
>

-- 
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] Nordic Perl Workshop and Mojoconf in Oslo

2018-05-08 Thread Jan Henning Thorsen
Sebastian is right: All talks will be in English.


On Tuesday, May 8, 2018 at 11:46:22 AM UTC+2, sri wrote:
>
> Is english main language for the conference talks?
>>
>
> Yes, i believe all talks will be in english.
>
> --
> 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] Nordic Perl Workshop and Mojoconf in Oslo

2018-05-08 Thread Jan Henning Thorsen
Nordic Perl Workshop 2018 will be held in Oslo, 6 - 7 September, 2018.

The conference topic is “Perl in the cloud”, with focus on web development, 
and deployment methods. We are pleased to announce that we will have 
members from the Mojolicious core team attending and a track dedicated to 
the Mojolicious real-time web framework.

* You can get information about tickets here: http://oslo.pm/npw2018/tickets
* And submit your talk here: http://oslo.pm/npw2018/
* Follow the hashtag #mojoconf and/or #npw2018 on Twitter for 
updates. https://twitter.com/marcusramberg/status/993750724608774144


See you later this year!

-- 
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: Is it possible to avoid repetitive validation code?

2018-02-27 Thread Jan Henning Thorsen
Yes. Put it in a helper:

$app->helper("validate.page" => sub { 
shift->validaton->optional('page')->num(1, 100) })

and use it as:

$c->validate->page;

Or you could also route condition or a "under route" where you add the 
validation before your action is called:

* http://mojolicious.org/perldoc/Mojolicious/Guides/Routing#Under
* http://mojolicious.org/perldoc/Mojolicious/Guides/Routing#Conditions
* http://mojolicious.org/perldoc/Mojolicious/Guides/Routing#Adding-conditions

On Tuesday, February 27, 2018 at 5:08:23 AM UTC+1, Michael Fung wrote:
>
> Hi All,
>
> I am trying out Mojolicious::Validator. It is very elegant. But, if many 
> actions take a optional "page" parameter, then I need to include something 
> like the following for all these actions.
>
> sub action1 {
>   ...
>
>   $validation->optional('page')->num(1,100);
>
>
> Is there a way to avoid this repetition while using Mojolicious::Validator?
>
>
> Thanks,
> Michael
>
>
>
>

-- 
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: Localization of validation messages

2018-02-18 Thread Jan Henning Thorsen
I've tried to be clever about this many times, and it always ends up in a 
huge mess. So instead of trying to detect the exact issue, I will rather 
just tell the user what needs to be done:

% if (validation->has_error('username') {
  <%=l 'You need to fill in a username, which needs to 
be...' %>
% }

The "<%=l' part is the same as <%= l('you need to...') %>, I just like to 
write it a "funny" way. The l() helper needs to do the actual translation 
for you, as you would with any other string in your application.

On Sunday, February 18, 2018 at 9:13:38 AM UTC+1, Miguel Prz wrote:
>
> I am using Mojolicious::Validator::Validation in my Web app.
> I have to translate the error messages, for example "required" should be 
> "requerido" (spanish).
> How can I do this?
>
>
>

-- 
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: Mojo::Base get all attributes names

2018-02-14 Thread Jan Henning Thorsen
Not quite sure what to call such a module, but I just wrote a proof of 
concept 
here: https://gist.github.com/jhthorsen/0ad4c5c84661588e89da910a08460e88


On Monday, February 5, 2018 at 11:14:06 AM UTC+1, Konstantin Cherednichenko 
wrote:
>
> Hello!
>
> Is there any easy way to get all attributes names?
>
> I tried to get it via ISA but I also got methods names... I just want to 
> get "propA" and "propB"...
> Could someone please help me?
>
> My example:
>
> #!/usr/bin/env perl
>
> package A;
> use Mojo::Base -base;
>
> has propA => 123;
> has propB => 'val';
>
> sub get_props_names
> {
> my $self = shift;
>
> my %names = ();
>
> {
> my $base_class = ref($self);
>
> no strict 'refs';
>
> foreach my $class ($base_class, @{"${base_class}::ISA"})
> {
> foreach my $name (keys %{"${class}::"})
> {
> $names{$name} ||= 1;
> }
> }
> };
>
> return [sort keys %names];
> }
>
> package main;
> use Mojo::Base -strict;
> use Data::Dumper;
>
> my $obj = A->new;
>
> say Dumper($obj->get_props_names);
>

-- 
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: Test buttons or links in Mojo::Test

2017-12-28 Thread Jan Henning Thorsen
I've always done this manually. Something like this:

$t->get_ok('/')->status_is(200)->element_exists('a[href*="msgid"]');
$t->get_ok($t->tx->res->dom->at('a[href*="msgid"]')->{href})->status_is(302)->header_like(Location
 
=> qr{something});
$t->get_ok($t->tx->res->headers->location)->status_is(200)->element_exists_not('a[href*="msgid="]');

I like how it's dynamic, but at the same time very explicit.

On Wednesday, December 27, 2017 at 4:52:54 AM UTC+1, yanni1...@g.ucla.edu 
wrote:
>
> Hello all,
>
> How do I test if 
> a button (e.g. http://auth.syllabus.space/auth/authenticator?msgid=0>" class="btn 
> btn-default btn-xs" style="font-size:x-small;color:black" > do not show 
> again) 
> or a link (e.g. http://auth.syllabus.space/aboutus>">About 
> Us) 
> works, using Mojo::Test? I want to make sure that when the user clicks on 
> them they can be redirected to the right page, and I want my test object to 
> follow those links and test the content of the new page.
>
> Thanks!
>
> Ni
>

-- 
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: Newbie question : How to run a bash script from inside a Mojolicious application ?

2017-10-31 Thread Jan Henning Thorsen
Hi,

You could also consider looking into these alternatives:

* https://metacpan.org/pod/Mojo::IOLoop::Subprocess - Run long running 
(blocking) code in a sub process
* https://metacpan.org/pod/Mojo::IOLoop::ForkCall - Pretty similar to 
Subprocess
* https://metacpan.org/pod/Mojo::IOLoop::ReadWriteFork - Similar to 
Subprocess/ForkCall, but you can write and read to the interactive process 
* https://metacpan.org/pod/Minion - Not quite the same, but it could be 
what you really want.


On Tuesday, October 31, 2017 at 1:50:32 AM UTC+8, Stefan Adams wrote:
>
>
>
> On Mon, Oct 30, 2017 at 8:56 AM, jay m  wrote:
>
>> pascal,
>>
>> system() and backticks work fine from a Mojolicious app. your problem is 
>> probably one of 3 things:
>>
>> * the environment inside the mojo app is different than your interactive 
>> shell environment. compare %ENV to your shell's printenv
>> * the current working directory when running the shell command isn't what 
>> you expected. try print `pwd`;
>> * the user running the mojo app doesn't have the right permissions for 
>> the command or files you're trying to use
>>
>
> Great advice.  I might also add that you need to consider how long the 
> bash script will take to execute and the impact it will have on the 
> Mojolicious application itself.  Being new to Mojolicious, I'd advise you 
> to read up on blocking and non-blocking operations 
> 
> .
>

-- 
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: client url

2017-10-31 Thread Jan Henning Thorsen
Hi,


Do you mean $c->req->url ?


On Tuesday, October 31, 2017 at 4:35:05 AM UTC+8, amka...@gmail.com wrote:
>
> Hi,
>
> How can I please get the client utl ?
>
> 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.


[Mojolicious] Re: A pair of processes using 8% of CPU each

2017-07-10 Thread Jan Henning Thorsen
Charlie,

I think I was tricked by the "ps" output you had. What is 
"/etc/e-smith/web/functions/index.daemon.cgi" ? Is that the mojo app or the 
cgi script? Can you show some code?

The reason why you're seeing the polling is because of the implementation 
in the CGI plugin. You can see it 
here: 
https://github.com/jhthorsen/mojolicious-plugin-cgi/blob/master/lib/Mojolicious/Plugin/CGI.pm#L35

Btw: I'm the author of the CGI plugin. I have not had any issues with it 
using a lot of CPU, even with that polling interval, but you can try to 
tweak it if you like, by 
setting 
https://github.com/jhthorsen/mojolicious-plugin-cgi/blob/master/lib/Mojolicious/Plugin/CGI.pm#L13

It could probably be fixed by the same code I added to ReadWriteFork. I 
will take a PR if anyone implements the change, where it uses EV::child(), 
if 
available: 
https://github.com/jhthorsen/mojo-ioloop-readwritefork/commit/42a579d5b78eedb0d01b7db25036ca1726819f18


On Friday, June 30, 2017 at 7:15:17 AM UTC+2, Henry Foolman wrote:
>
> Hi Charly,
> missing some details.
> 1.) OS Version
> 2.) Kernel Version
> 3.) mojo version.
> 4.) Do you use cpan(m) to install the lastest version or are you using OS 
> packages ?
>
> I had similar problems but switched to a new mojo version and latest EV. ( 
> cpanm EV).
> For EV it should be kernel > 4.5
> It seems that you started your app via daemon.
> Try to use hypnotoad and check if there are changes. (got to the base dir 
> and enter hypnotoad -f script/yourscript).
> Some hints about reading and writing to a process.
> I use Mojo::IOLoop::ReadWriteFork togehter with the delay helper 
> ($c->delay), which works perfectly.
> Perhaps it's this your're looking for.
>
> Rgds.
> Hans
>
>
> Am Donnerstag, 29. Juni 2017 16:10:46 UTC+2 schrieb Charlie Brady:
>>
>>
>> On Thu, 29 Jun 2017, Jan Henning Thorsen wrote: 
>>
>> > Hey, 
>> > 
>> > It doesn't look like "daemon" mode. It looks like you used "morbo" to 
>> start 
>> > the application. 
>>
>> I don't know what makes you say that. I definitely was using "daemon" 
>> mode 
>> and was not using "morbo". 
>>
>> I didn't track down exactly what code was making the difference in the 
>> poll timeout, but worked out that it was somewhere in the CGI plugin. 
>> I've 
>> eliminated the CGI plugin and now find that the poll timeout is back to 
>> 1000 ms, which a corresponding reduction in idle CPU. 
>>
>> I don't know exactly where the fork() was which lead to the pair of 
>> processes. I did have some code with an open() reading from a pipe, but I 
>> wouldn't expect to see poll() in the child process in that case. 
>>
>> Mystery not quite solved, but now that I am not using the CGI plugin I at 
>> least don't have an ongoing problem. 
>>
>> Thanks for commenting. If you want to try to identify the problem with 
>> the 
>> CGI plugin I can re-insert that code. 
>>
>> > 
>> > 
>> > On Wednesday, June 14, 2017 at 11:11:31 PM UTC+2, Charlie Brady wrote: 
>> > > 
>> > > 
>> > > I'm running a Mojolicious UI in daemon mode on a PowerPC embedded 
>> system 
>> > > (running Wind River Linux, perl 5.22.0, kernel 4.1.21) and notice 
>> > > surprisingly high CPU usage on a totally idle UI. 
>> > > 
>> > > I can see that there are two processes. Each process is in a polling 
>> loop 
>> > > with 10ms timeout. I don't expect to see two processes here, so I 
>> wonder 
>> > > whether this is normal or abnormal behaviour. If it is normal 
>> behaviour, 
>> > > can I tune down the 10ms timeout to something longer? I would like to 
>> see 
>> > > the process block until there is actual work to do. 
>> > > 
>> > > root@10:/service# ps fax | grep index.daemon-5 
>> > >  1418 pts/1S+ 0:00  \_ grep index.daemon 
>> > > 19303 ?Ssl   24:24 
>> /etc/e-smith/web/functions/index.daemon.cgi 
>> > > 24397 ?Ssl   20:54  \_ 
>> /etc/e-smith/web/functions/index.daemon.cgi 
>> > > root@10:/service# strace -p19303 -tt 2>&1 | head -5 
>> > > Process 19303 attached 
>> > > 17:05:08.095154 restart_syscall(<... resuming interrupted call ...>) 
>> = 0 
>> > > 17:05:08.104465 poll([{fd=21, events=POLLIN|POLLPRI|POLLOUT}], 1, 9) 
>> = 0 
>> > > (Timeout) 
>> > > 17:05:08.116478 poll([{fd=21, events=POLLIN|POLLPRI|POLLOUT}], 1, 10) 
>> = 0 
>> > > (Timeout) 
&g

[Mojolicious] Re: A pair of processes using 8% of CPU each

2017-06-29 Thread Jan Henning Thorsen
Hey,

It doesn't look like "daemon" mode. It looks like you used "morbo" to start 
the application.


On Wednesday, June 14, 2017 at 11:11:31 PM UTC+2, Charlie Brady wrote:
>
>
> I'm running a Mojolicious UI in daemon mode on a PowerPC embedded system 
> (running Wind River Linux, perl 5.22.0, kernel 4.1.21) and notice 
> surprisingly high CPU usage on a totally idle UI. 
>
> I can see that there are two processes. Each process is in a polling loop 
> with 10ms timeout. I don't expect to see two processes here, so I wonder 
> whether this is normal or abnormal behaviour. If it is normal behaviour, 
> can I tune down the 10ms timeout to something longer? I would like to see 
> the process block until there is actual work to do. 
>
> root@10:/service# ps fax | grep index.daemon-5 
>  1418 pts/1S+ 0:00  \_ grep index.daemon 
> 19303 ?Ssl   24:24 /etc/e-smith/web/functions/index.daemon.cgi 
> 24397 ?Ssl   20:54  \_ /etc/e-smith/web/functions/index.daemon.cgi 
> root@10:/service# strace -p19303 -tt 2>&1 | head -5 
> Process 19303 attached 
> 17:05:08.095154 restart_syscall(<... resuming interrupted call ...>) = 0 
> 17:05:08.104465 poll([{fd=21, events=POLLIN|POLLPRI|POLLOUT}], 1, 9) = 0 
> (Timeout) 
> 17:05:08.116478 poll([{fd=21, events=POLLIN|POLLPRI|POLLOUT}], 1, 10) = 0 
> (Timeout) 
> 17:05:08.130120 poll([{fd=21, events=POLLIN|POLLPRI|POLLOUT}], 1, 9) = 0 
> (Timeout) 
> root@10:/service# strace -p24397 -tt 2>&1 | head -5 
> Process 24397 attached 
> 17:05:12.888643 restart_syscall(<... resuming interrupted call ...>) = 0 
> 17:05:12.894814 poll([{fd=21, events=POLLIN|POLLPRI|POLLOUT}], 1, 10) = 0 
> (Timeout) 
> 17:05:12.908082 poll([{fd=21, events=POLLIN|POLLPRI|POLLOUT}], 1, 10) = 0 
> (Timeout) 
> 17:05:12.920771 poll([{fd=21, events=POLLIN|POLLPRI|POLLOUT}], 1, 10) = 0 
> (Timeout) 
> root@10:/service# top | head -12 
> top - 17:09:31 up 9 days,  7:59,  4 users,  load average: 0.73, 0.59, 0.60 
> Tasks:  98 total,   1 running,  95 sleeping,   0 stopped,   2 zombie 
> %Cpu(s): 12.9 us,  5.7 sy,  3.8 ni, 75.7 id,  1.8 wa,  0.0 hi,  0.1 si,   
> 0.0 st 
> KiB Mem :   995536 total, 5428 free,   317100 used,   673008 
> buff/cache 
> KiB Swap:65532 total,65448 free,   84 used.   594360 avail Mem 
>
>   PID USER  PR  NIVIRTRESSHR S %CPU %MEM TIME+ COMMAND 
>   
>  1440 root  20   03852   2280   1924 R 24.0  0.2   0:00.13 top 
>   
>   508 root  20   0  134908  69156  13896 S 12.0  6.9 465:50.05 
> call_control 
> 19303 root  20   0   87812  37720   4148 S  8.0  3.8  24:45.37 
> /etc/e-smith/we   
> 24397 root  20   0   87788  37184   3552 S  8.0  3.7  21:13.65 
> /etc/e-smith/we   
>   425 root  20   0   16068  10284   3640 S  4.0  1.0  33:32.22 snmpd   
>   
>

-- 
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: Static cache header plugin

2017-06-29 Thread Jan Henning Thorsen
Hey,

I think you 
want 
https://metacpan.org/source/LDIDRY/Mojolicious-Plugin-StaticCache-0.01/lib/Mojolicious/Plugin/StaticCache.pm#L15
 
to be this:

if ($mode ne 'development' || $even_in_dev) {

And I think I would store $mode and $even_in_dev outside of the 
"after_static" hook.


On Thursday, June 22, 2017 at 10:58:03 AM UTC+2, Luc Didry wrote:
>
> Hello, 
>
> As discussed on the "Wishlist thread (fourth edition)"[1], I made a 
> Mojolicious 
> Plugin which add Cache-Control header on served static files in production 
> (the 
> header is not added in development mode): 
> https://metacpan.org/pod/Mojolicious::Plugin::StaticCache 
>
> It's basic and has very few options but it does the job. 
>
> The code is on https://framagit.org/luc/mojolicious-plugin-staticcache 
> and 
> issues should be opened on 
> https://framagit.org/luc/mojolicious-plugin-staticcache/issues. 
>
> (if you don't have a framagit.org account, you can use Github 
> authentication to 
> get one in a few clicks). 
>
> Comments and code contribution are welcome  
>
> [1] 
> https://groups.google.com/forum/#!searchin/mojolicious/wishlist|sort:relevance/mojolicious/JLZlJwkm0Ho/mFE8CFIcAAAJ
>  
> -- 
> 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] Re: Mojolicious application to show markdown as slides

2017-01-09 Thread Jan Henning Thorsen
Wow! Thanks for finding bugs. That's a lot more than I expected :) 
Appreciate it.


On Monday, January 9, 2017 at 8:49:41 AM UTC+1, mimosinnet wrote:
>
> Seriously, I learning reading your code. Actually, I am still 
> understanding the combination of 'grep' and 'map' in getting the @files. 
> Definitively, I can see the beauty of having the app in one file. 
> Nevertheless, as I am still in the baby-perl stage and I find easier to 
> organise the code in a full app and find bugs when displaying the markdown 
> as slides <http://presentacions.mimosinnet.org/presenta/01/1>.   
>
> Also, I think I have found a bug. I have created a directory structure:
> mkdir -p D1/D2/D3/D4
>
> If I go to the following url (with chromium and firefox):
> http://127.0.0.1:3000/D1/D2/D3
>
> I get the following link for D4:
> http://127.0.0.1:3000/D1/D2/D1/D2/D3/D4
>
> Nevertheless, if I inspect the html code, it shows as... :O :
> D4
>
> This is solved if instead of:
> $c->render(template => 'browser', web_dir => $web_dir, files => \@files);
>
> We turn the path into an absolute string:
> $c->render(template => 'browser', web_dir => $web_dir->to_abs_string, 
> files => \@files);
>
> It has taken me a while to find what the issue was as the output of 
> "$web_dir/$file->[0]" showed the right value. ;-) 
>
> Cheers! 
>
> El diumenge, 8 gener de 2017 13:14:17 UTC+1, Jan Henning Thorsen va 
> escriure:
>>
>> Thank you for all the kind words! :)
>>
>> One of the ideas with my version (or any application that I write) is 
>> that I want them to be very easy to download/run. That's why I put all the 
>> code in one file and avoid any use of database access.
>>
>> Another thing I could mention, is that I added a quick hack to support 
>> code formatting using ```perl...```:
>>
>> * https://github.com/jhthorsen/app-mdweb/blob/master/script/mdweb#L5
>> * https://github.com/jhthorsen/app-mdweb/blob/master/script/mdweb#L36-L39
>> * https://github.com/jhthorsen/app-mdweb/blob/master/script/mdweb#L47
>>
>>
>> Please steal anything you find interesting :-)
>>
>>
>> On Sunday, January 8, 2017 at 1:45:13 AM UTC+1, mimosinnet wrote:
>>>
>>> Thanks a lot Jan!
>>>
>>> I have enjoyed your code, discovering I have a lot to learn ;-) It has 
>>> been very useful seeing your use of Mojo::Path and the way you read files 
>>> and directories. I will try this in my code. I will also try to understand 
>>> the more idiomatic parts of your code :D
>>>
>>> Cheers! 
>>>
>>> El dissabte, 7 gener de 2017 15:28:55 UTC+1, Jan Henning Thorsen va 
>>> escriure:
>>>>
>>>> Hi,
>>>>
>>>> Not sure if this is interesting, but I have a competing project for 
>>>> rendering markdown files. Haven't gotten around to complete it...
>>>>
>>>> https://github.com/jhthorsen/app-mdweb
>>>>
>>>>
>>>> On Tuesday, January 3, 2017 at 2:22:21 AM UTC+1, mimosinnet wrote:
>>>>>
>>>>> I have been working this Christmas in an application to show markdown 
>>>>> files as slides:
>>>>>
>>>>>- Code in github <https://github.com/mimosinnet/presentation>
>>>>>- Slides outline <http://presentacions.mimosinnet.org/diapos/01>
>>>>>- Slides <http://presentacions.mimosinnet.org/presenta/01/1>
>>>>>
>>>>> The markdown is stored public/md/*number_of_presentation*, and the 
>>>>> media for the presentation in public/*number_of_presentation. *Each 
>>>>> slide is saved in a sqlite database, and the first line of the slide is 
>>>>> used as the slide background if it is an image. I will happily add more 
>>>>> documentation and include suggestions if considered relevant. 
>>>>>
>>>>> Long story:
>>>>> I have been using *pinpoint*  <https://wiki.gnome.org/Apps/Pinpoint>for 
>>>>> my presentations in my work as teacher on psychology. For different 
>>>>> reasons 
>>>>> (lack of development, availability,...) I started to seek for 
>>>>> alternatives, 
>>>>> and it seems that html/css/javascript 
>>>>> <http://bashooka.com/coding/html-css-based-presentation-slides/> is 
>>>>> the way forward. Unfortunately, as I do not have any 
>>>>> javascript/jquery/ajax 
>>>>> skills, I have used my limited Perl knowledge to build something with 
>>>>> Mojolicious. I have spend this Christmas having fun (an addiction) with 
>>>>> web 
>>>>> development ;-). I hope this can be useful for other Mojolicious 
>>>>> beginners. 
>>>>>
>>>>> Cheers! 
>>>>>
>>>>

-- 
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: Mojolicious application to show markdown as slides

2017-01-08 Thread Jan Henning Thorsen
Thank you for all the kind words! :)

One of the ideas with my version (or any application that I write) is that 
I want them to be very easy to download/run. That's why I put all the code 
in one file and avoid any use of database access.

Another thing I could mention, is that I added a quick hack to support code 
formatting using ```perl...```:

* https://github.com/jhthorsen/app-mdweb/blob/master/script/mdweb#L5
* https://github.com/jhthorsen/app-mdweb/blob/master/script/mdweb#L36-L39
* https://github.com/jhthorsen/app-mdweb/blob/master/script/mdweb#L47


Please steal anything you find interesting :-)


On Sunday, January 8, 2017 at 1:45:13 AM UTC+1, mimosinnet wrote:
>
> Thanks a lot Jan!
>
> I have enjoyed your code, discovering I have a lot to learn ;-) It has 
> been very useful seeing your use of Mojo::Path and the way you read files 
> and directories. I will try this in my code. I will also try to understand 
> the more idiomatic parts of your code :D
>
> Cheers! 
>
> El dissabte, 7 gener de 2017 15:28:55 UTC+1, Jan Henning Thorsen va 
> escriure:
>>
>> Hi,
>>
>> Not sure if this is interesting, but I have a competing project for 
>> rendering markdown files. Haven't gotten around to complete it...
>>
>> https://github.com/jhthorsen/app-mdweb
>>
>>
>> On Tuesday, January 3, 2017 at 2:22:21 AM UTC+1, mimosinnet wrote:
>>>
>>> I have been working this Christmas in an application to show markdown 
>>> files as slides:
>>>
>>>- Code in github <https://github.com/mimosinnet/presentation>
>>>- Slides outline <http://presentacions.mimosinnet.org/diapos/01>
>>>- Slides <http://presentacions.mimosinnet.org/presenta/01/1>
>>>
>>> The markdown is stored public/md/*number_of_presentation*, and the 
>>> media for the presentation in public/*number_of_presentation. *Each 
>>> slide is saved in a sqlite database, and the first line of the slide is 
>>> used as the slide background if it is an image. I will happily add more 
>>> documentation and include suggestions if considered relevant. 
>>>
>>> Long story:
>>> I have been using *pinpoint*  <https://wiki.gnome.org/Apps/Pinpoint>for 
>>> my presentations in my work as teacher on psychology. For different reasons 
>>> (lack of development, availability,...) I started to seek for alternatives, 
>>> and it seems that html/css/javascript 
>>> <http://bashooka.com/coding/html-css-based-presentation-slides/> is the 
>>> way forward. Unfortunately, as I do not have any javascript/jquery/ajax 
>>> skills, I have used my limited Perl knowledge to build something with 
>>> Mojolicious. I have spend this Christmas having fun (an addiction) with web 
>>> development ;-). I hope this can be useful for other Mojolicious beginners. 
>>>
>>> Cheers! 
>>>
>>

-- 
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: Mojolicious application to show markdown as slides

2017-01-07 Thread Jan Henning Thorsen
Hi,

Not sure if this is interesting, but I have a competing project for 
rendering markdown files. Haven't gotten around to complete it...

https://github.com/jhthorsen/app-mdweb


On Tuesday, January 3, 2017 at 2:22:21 AM UTC+1, mimosinnet wrote:
>
> I have been working this Christmas in an application to show markdown 
> files as slides:
>
>- Code in github 
>- Slides outline 
>- Slides 
>
> The markdown is stored public/md/*number_of_presentation*, and the media 
> for the presentation in public/*number_of_presentation. *Each slide is 
> saved in a sqlite database, and the first line of the slide is used as the 
> slide background if it is an image. I will happily add more documentation 
> and include suggestions if considered relevant. 
>
> Long story:
> I have been using *pinpoint*  for 
> my presentations in my work as teacher on psychology. For different reasons 
> (lack of development, availability,...) I started to seek for alternatives, 
> and it seems that html/css/javascript 
>  is the 
> way forward. Unfortunately, as I do not have any javascript/jquery/ajax 
> skills, I have used my limited Perl knowledge to build something with 
> Mojolicious. I have spend this Christmas having fun (an addiction) with web 
> development ;-). I hope this can be useful for other Mojolicious beginners. 
>
> Cheers! 
>

-- 
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 stop rendering after user error?

2016-12-04 Thread Jan Henning Thorsen
I think this is code smell. There's probably a much better design pattern 
you can use, than using an exception to stop rendering. I would try my best 
to avoid this pattern and look for some other solution.


On Thursday, December 1, 2016 at 6:52:29 PM UTC+1, Peter Valdemar Mørch 
wrote:
>
> Say in my controller I'm 5 levels deep and discover there is a problem 
> with the user's input. I call:
>
> $c->render(
> template => 'errors/badValues',
> message => 'The value of foo cannot be "bar"',
> );
>
> And now I want to stop the entire request right there. I guess the 
> behaviour I'm looking for is that of an exception - return up the call 
> stack - without having to do something with a return value and then
>
> callSub()
>   or return;
>
> at every stack level. So what I've done is create an exception type and 
>
> $c->render(
> template => 'errors/badValues',
> message => 'The value of foo cannot be "bar"',
> );
> die(StopRenderingException->new());
>
> And then in setup:
>
> $self->hook( around_dispatch => sub {
> my ( $next, $c ) = @_;
> eval {
> $next->();
> };
> if ($@) {
> my $err = $@;
> if (blessed($err) && $err->isa('StopRenderingException')) {
> return;
> } else {
> die $err;
> }
> }
> });
>
> It does have a hacky smell to it though. Is there a better best-practice?
>
> Peter
>

-- 
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: form validation

2016-12-04 Thread Jan Henning Thorsen
Hey,

Not sure if I understand your problem, but why don't you just use 
$c->validation? Have a look here for more information and 
examples: 
https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Rendering.pod#Form-validation

Which version of Mojolicious do you have? Run "mojo version" to check the 
version.


On Saturday, December 3, 2016 at 1:55:41 PM UTC+1, amka...@gmail.com wrote:
>
> And when I put
>
> my $names = $validation->failed;
>
> I have this message :
>
> Can't locate object method "failed" via package 
> "Mojolicious::Validator::Validation" at 
> /home/amka/job/RAD/mojo/03/script/../lib/MyApp/Controller/En.pm line 35.
>
>
>

-- 
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: Mojo::JSON->true encoded as 1 instead of true

2016-09-28 Thread Jan Henning Thorsen
Hey,

I think your issue is elsewhere. That code should work as expected. You can 
also try it out with a one-liner:

$ perl -le'use Mojo::JSON "encode_json"; print encode_json {flag => 
Mojo::JSON->true}'
{"flag":true}


On Wednesday, September 28, 2016 at 9:31:56 AM UTC+2, Lachlan Deck wrote:
>
> Hi all,
>
> I'm using Mojolicious as a mock server, and I can't seem to encode 
> booleans as real booleans (i.e., true or false).
>
> Mojo::JSON->true seems to be encoded as 1 instead of true, for example.
>
> What might I be missing?
>
>
> use Mojo::JSON qw(decode_json encode_json);
> ...
>
> get '/foo' => sub {
>   my $c = shift;
>   my $data = encode_json {
> ...
> flag => Mojo::JSON->true
>   };
>
>   $c->render(text => 'foo', data => $data);
> }
>
> cheers,
> Lachlan
>

-- 
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] IOLoop Connections

2016-07-27 Thread Jan Henning Thorsen
The list of events are right there in the 
documentation: https://metacpan.org/pod/Mojo::IOLoop::Server#EVENTS

On Wednesday, July 13, 2016 at 2:11:44 AM UTC+2, Brian Shaw wrote:
>
> Thanks.  That worked well.  Do you know if there is a complete list of 
> events?
>
> Brian
>
>
> On Sunday, July 10, 2016 at 5:46:06 PM UTC-4, Alex Alex wrote:
>>
>> You could use Mojo::IOLoop::Server; accept event.
>> https://metacpan.org/pod/Mojo::IOLoop::Server
>>
>>
>>
>>   Is there a way to tell when a client has completed the initial 
>> connection to the server, as opposed to any other time in the life of the 
>> connection?
>>   With HTTP(S) you just sit and wait until the client says something like 
>> "GET /".
>>   I'm trying to write a mail server and the SMTP protocol specifies that 
>> the server, not the client, starts the conversation once the client 
>> connects.
>>   If there is some way outside of IOLoop to do this, I'm okay with 
>> changing directions.
>>   Thanks for any suggestions or code snippets.
>>
>> Brian
>> -- 
>> 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] Re: How to find out the name of a placeholder the route is using

2016-07-27 Thread Jan Henning Thorsen
Why not just hard-code %url_params? Often it will be a lot more obvious to 
see what you're actually passing on.

  $url_params{foo} = $db_row->{whatever};

I used to think making everything very dynamic was a good idea. I don't 
anymore. There's a bunch of cases where being specific can make the code 
easier to read and less exposed to bugs.


On Friday, July 22, 2016 at 3:12:52 AM UTC+2, Randall Sindlinger wrote:
>
> Hi,
>
> I'd like to take a given named route, and ask what the placeholders are 
> that it expects.
>
> I'm trying to do a relatively simple call of
> $c->url_for( $route_name, \%url_params );
>
> However, the keys for %url_params are coming out of database tables, and 
> I've run into a case where the logic is breaking down when I create the 
> key.  (it's trying to append '_identifier' to the column name when it 
> shouldn't).
>
> I'd like to be able to check if the key name that is created matches the 
> placeholder name used by the route before calling out to url_for.
>
> It looks like if I do
> $foo=$c->app->routes->find($route_name)
> that then I can see the placeholder underneath
> $foo->pattern->tree
>
> But I feel like I'm diving too deep into it.  Is there a better way?
>
> Thanks in advance for any thoughts,
> -Randall
>

-- 
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: Deployment: launch hypnotoad on boot

2016-07-27 Thread Jan Henning Thorsen
I just use cron for starting on boot:

  $ crontab -l
  @reboot /path/to/myserver.sh 1>>/path/to/log/file.log 
2>>/path/to/log/file.log

The reason why I have a shell script first is to set up %ENV and friends. 
If you don't need that, then you can just point directly to the 
application. I also sometimes add a hack to the shell script to see if a 
given database is started if the application require that to start up.

So... this is a rather hackish solution for the complicated, but (for me) a 
very simple solution for the simple cases. I would say using upstart. initv 
or systemd is a lot cleaner though, but it *might* require more work.


On Friday, July 22, 2016 at 12:44:57 PM UTC+2, Gabor Szabo wrote:
>
> Hi,
>
> I am trying to deploy a Mojolicious-based application on an Ubuntu server.
> When I launch the application with hypnotoad everything is fine, but I 
> wonder what is the recommended way to make the Hypnotoad server launch when 
> I reboot the Linux box?
>
> I looked at 
> http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#DEPLOYMENT but 
> could not find this information.
>
> regards
>Gabor
>

-- 
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: Secrets Question

2016-06-28 Thread Jan Henning Thorsen
How does the start of that package look like? Do you have this:

  package MyApp;
  use Mojo::Base "Mojolicious";

The string after "package" need to match whatever you pass on 
to start_app().

Another thing: I would not run my code as "root". If you want to listen to 
port 80, I would advice using 
https://metacpan.org/pod/Mojolicious::Plugin::SetUserGroup to make sure 
that the requests run as different user.


On Monday, June 27, 2016 at 5:49:05 PM UTC+2, James Bearden wrote:
>
> Sure, below is the top of my startup routine. I get the "passphrase needs 
> to be changed" warning before this code is executed.
>
> # This method will run once at server start
> sub startup {
>   my $Self = shift;
>   
>   if ($Self->app->mode eq 'development') {
> $Self->app->log->level('info'); # debug, (info), warn, error, or fatal
>   } elsif (getpwuid($>) eq 'root') {
> $Self->app->log->info("Server starting!");
> $Self->app->log->level('warn');
>   } else {
> NeoUtil::LogThis("Must be run as root!");
> return;
>   }
>
>   # Set name for the mojolicious cookie. Maximum cookie size is 4096 bytes.
>   $Self->sessions->cookie_name('MyApp');
>
>   # Key to encode client cookie, which stores some session information.
>   
> $Self->secrets(['uBLR8eIgsIQ7MmZ0nfyd5UOdd48VlnUGrjYyS9regRX72qEO2b0UlQ738a',
>   '30J0SEIIF3UQzLYZNrgD2sh9Zm3DgYjzaN9RRmi8k1Gs0SBNk7tzd2dPg']);
>
>
>
> And the output I am getting is:
>
> Server available at http://127.0.0.1:3000
> [Mon Jun 27 10:47:32 2016] [debug] Your secret passphrase needs to be 
> changed
>
>
>
>
> On Monday, June 27, 2016 at 10:44:06 AM UTC-5, Pavel K wrote:
>>
>> Can you show me this part of code?
>> 27 июня 2016 г. 17:55 пользователь "James Bearden"  
>> написал:
>>
>>> That is unfortunately exactly what I have been doing, and I still get 
>>> the warning upon startup.
>>>
>>> On Sunday, June 26, 2016 at 2:24:57 PM UTC-5, Pavel K wrote:

 I think something like this must be to work fine

 sub startup {
 my $self = shift;
 $self->secrets(['stu15684ffy','tea5$6ching']);
 ...

 }

 -- 
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "Mojolicious" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/mojolicious/EYWg8GEPg9Y/unsubscribe.
>>> To unsubscribe from this group and all its topics, 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] Re: Using IO::Loop on websocket connection

2016-05-02 Thread Jan Henning Thorsen
I don't get why you put that code inside delay().

I would suggest moving it out of delay and right into the websocket sub.

What are you trying to accomplish by putting it inside delay()?


On Friday, April 29, 2016 at 3:20:29 PM UTC+2, Matija Papec wrote:
>
>
> When I set websocket events inside $c->delay() browser disconnects almost 
> immediately ("finish" event is properly triggered).
> Please explain what is wrong here.
>
> ==
> use Mojolicious::Lite;
>
> websocket '/ws/:sessid' => sub {
> my ($c) = @_;
>
> $c->delay(sub{
> $c->on(finish => sub { warn "disconnect\n" });
> $c->on(json => sub { warn "incoming ws json \n" });
> });
> };
>
>
>

-- 
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: Posting with useragent after rendering

2016-04-28 Thread Jan Henning Thorsen
Ivan: It's not a safe thing to do "something else" after the request has 
been sent to the client. At least not if you use hypnotoad / prefork. The 
reason for this is that the children gets recycled from time to time, and 
doing that might kill the outgoing request.

I would much rather suggest putting minion or some other queue system in 
the middle which can handle the slow requests.


On Wednesday, April 27, 2016 at 3:28:45 PM UTC+2, Iván Aponte wrote:
>
> Hello, 
>
> Thanks. The error was that I was creating my own UserAgent and not using 
> the helper in the controller.
>
> On Tuesday, April 26, 2016 at 10:31:10 PM UTC-4:30, Scott Wiersdorf wrote:
>>
>> No, the UA here is part of the controller object that doesn't go out of 
>> scope. You're doing something else wrong but we can't see it from here.
>>
>> In terminal 1, example.pl:
>> #!/usr/bin/env perl
>> use Mojolicious::Lite;
>>
>> post '/' => sub {
>>   my $c = shift;
>>   $c->render(json => {message => "worked"});
>> };
>>
>> app->start;
>>
>> $ ./example.pl daemon -l "http://*:3000;
>>
>> In terminal 2, caller.pl:
>> #!/usr/bin/env perl
>> use Mojolicious::Lite;
>>
>> get '/' => sub {
>> my $c = shift;
>> $c->ua->post(
>> 'http://localhost:3000',
>> sub {
>> my ($ua, $tx) = @_;
>> $c->app->log->debug($c->app->dumper($tx->res->json));
>> }
>> );
>>
>> $c->render(status => 200, data => "thanks");
>> };
>>
>> app->start;
>>
>> $ ./caller.pl daemon -l "http://localhost:3001;
>>
>> In a 3rd terminal:
>>
>> $ curl http://localhost:3001/
>> thanks
>>
>> Logs for example:
>> $ ./example daemon -l "http://*:3000;
>> [Tue Apr 26 20:58:33 2016] [info] Listening at "http://*:3000;
>> Server available at http://127.0.0.1:3000
>> [Tue Apr 26 20:58:36 2016] [debug] POST "/"
>> [Tue Apr 26 20:58:36 2016] [debug] Routing to a callback
>> [Tue Apr 26 20:58:36 2016] [debug] 200 OK (0.000603s, 1658.375/s)
>>
>> Logs for caller.pl:
>>
>> $ ./caller daemon -l "http://localhost:3001;
>> [Tue Apr 26 20:56:44 2016] [info] Listening at "http://localhost:3001;
>> Server available at http://localhost:3001
>> [Tue Apr 26 20:58:36 2016] [debug] GET "/"
>> [Tue Apr 26 20:58:36 2016] [debug] Routing to a callback
>> [Tue Apr 26 20:58:36 2016] [debug] 200 OK (0.000994s, 1006.036/s)
>> [Tue Apr 26 20:58:36 2016] [debug] {
>>   "message" => "worked"
>> }
>>
>> Working as advertised.
>>
>> Scott
>>
>> On Tuesday, April 26, 2016 at 6:29:48 PM UTC-6, Iván Aponte wrote:
>>>
>>> Hello,
>>>
>>> I just tried the way you suggest but got the same error. Seems to me 
>>> that UA goes out of scope and dies. Is there a way to prevent this
>>>
>>> Regards, 
>>>
>>> IA
>>>
>>> On Tuesday, April 26, 2016 at 7:39:19 PM UTC-4:30, Scott Wiersdorf wrote:

 Is there a reason you can't do something like this?:

 sub res1{
   my $c=shift;
   $c->ua->post('http://www.example.com', sub {
 my ($uax, $txx) = @_;
  $c->app->log->debug(Dumper($txx));
   });

   $c->render(status=>200,data=>'');
 }

 The way you're doing it, the transaction goes out of scope which is 
 probably why you get the premature connection close. In the above example, 
 the post() will return immediately, allowing the render() to execute next. 
 The post() response will be handled asynchronously whenever it comes back. 

 Scott

 On Tuesday, April 26, 2016 at 5:57:17 PM UTC-6, Iván Aponte wrote:
>
>  Hello, 
>
> I have the following problem. I have a service which gets call, it 
> must answer with 200, close the connection and post to another web 
> service. 
> If I do it in a non-blocking way premature closing occurs. 
>
> E.g. : 
>
> sub res1{
>   my $c=shift;
>$c->render(status=>200,data=>'');
>my $ua = Mojo::UserAgent->new;
>my $tx = $ua->build_tx(POST => 'http//www.example.com');
>$ua->start($tx=> sub{
> my ($uax, $txx) = @_;
>  $c->app->log->debug(Dumper($txx));
>});
> }
>
>
>
> Is there a way to make a post after rendering without blocking ?
>
>
> Thanks, 
>
> IA
>


-- 
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-23 Thread 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] Re: How to use production.log under command line ?

2016-03-23 Thread Jan Henning Thorsen
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 , 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 restrict quantity of the concurrent connections TO REMOTE server using Mojo::UserAgent

2016-03-10 Thread Jan Henning Thorsen
There's no limit on how many connections Mojo::UserAgent can make, so you 
have to restrict that yourself. Something like this might work:

  my $mainarray = [];
  my $ua = Mojo::UserAgent->new;
  my $gather;

  $gather = sub {
my ($ua, $tx) = @_;
my $graphname = "whatever";
$tx->res->content->asset->move_to($graphname);
return $ua->emit('completely_done') unless @$mainarray;
return $ua->get(shift(@$mainarray)->{graphURL}, $gather);
  };

  $ua->on(completely_done => sub { Mojo::IOLoop->stop });

  for (1..40) {
my $mhash = shift @$mainarray or last;
$ua->get($mhash->{graphURL}, $gather);
  }

  Mojo::IOLoop->start;


On Thursday, March 10, 2016 at 12:00:58 AM UTC+1, Юрий Корик wrote:
>
> Hello guys.
>
> I've wrote script like this to get about 2000 charts from Graphite:
>
>
> use Mojo::UserAgent;
> use Mojo::IOLoop;
>
> my $ua = Mojo::UserAgent->new;
>
> foreach my $mhash (@{$mainarray}) {
>   $ua->get($mhash->{graphURL} => sub {
>my ($ua, $tx) = @_;
>$tx->res->content->asset->move_to($graphname);
>   });
> }
>
> Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
>
> 1;
>
> How can I restrict Mojo::UserAgent to create only 40 concurrent connection 
> to remote server?
>
> With best regards, Yuriy.
>

-- 
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: Hosting Mojolicious project in web Server

2016-02-26 Thread Jan Henning Thorsen
Why are you using mod_perl? Can't you use mod_proxy?

https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Cookbook.pod#Apache-mod_proxy


On Friday, February 26, 2016 at 9:32:05 AM UTC+1, Alex Alex wrote:
>
> Using apache + mod_perl with mojolicious isn't very wise decision.
>
> I suggest iptables + hypnotoad or nginx + hypnotoad . Both of them are 
> much simpler and faster
>
>
>
>
>
> Hello Thorsen, 
>
> Thanks for the reply, Tried deploying the mojolicious application with 
> Apache using 'mod_perl' which is working, still having few issues like 
> routing and timeouts
>
>
> <https://lh3.googleusercontent.com/-X9WknYMwu54/VtAJMt8izOI/AAM/KUp7iDJcpKg/s1600/error.jpg>
>
> when its opened in a new tab or on refreshing the page, sometime its 
> works. 
>
>
> Am looking forward for the solution, thanks in advance.
>
>
>
>
>
> My* Virtual Host Configuration *looks something like this :-
>
>
> 
> DocumentRoot /path/app
> SetEnv APPLICATION_ENV 'development' 
> 
> Order deny,allow
> Allow from all
> 
> 
> $ENV{PLACK_ENV} = 'production';
> $ENV{MOJO_HOME} = '/path/app';
> $ENV{MOJO_MODE} = 'deployment';
> 
> 
> SetHandler perl-script
> PerlResponseHandler Plack::Handler::Apache2
> PerlSetVar psgi_app /path/app
> AllowOverride None
> # Allow open access:
>
> Require all granted
>
> 
>
> 
>
>
>
> On Monday, February 22, 2016 at 9:24:15 PM UTC+5:30, Jan Henning Thorsen 
> wrote: 
>>
>> Hi,  
>>
>> Have you looked at any of these resources:
>>
>> * 
>> https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Cookbook.pod#DEPLOYMENT
>> * 
>> https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Cookbook.pod#Apache-mod_proxy
>> * 
>> https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Cookbook.pod#Making-your-application-installable
>>
>> You might be interested in these projects as well:
>>
>> * https://metacpan.org/pod/Carmel
>> * https://metacpan.org/pod/Carton
>>
>> Carmel is the successor of Carton, which is a tool for bundling 
>> dependencies with your application.
>>
>>
>> Best regards,
>> Jan Henning Thorsen
>>
>>
>> On Monday, February 22, 2016 at 2:44:57 PM UTC+1, 
>> moulees...@jothisoftware.com wrote: 
>>>
>>>  Hello everyone, i had completely developed an application in perl with 
>>> mojolicious framework. since i am new to perl and its frameworks i don't 
>>> know how to *upload the project to the server* or* hosting the project 
>>> online*. if it is possible to host the project with* apache server*. 
>>> well and good , please let me know how to do it! and also tell me know the 
>>> *other 
>>> ways of deploying* the project online. Thanks in advanced.
>>>
>> -- 
> 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.
>
>
>

-- 
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: Hosting Mojolicious project in web Server

2016-02-22 Thread Jan Henning Thorsen
Hi,

Have you looked at any of these resources:

* 
https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Cookbook.pod#DEPLOYMENT
* 
https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Cookbook.pod#Apache-mod_proxy
* 
https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Cookbook.pod#Making-your-application-installable

You might be interested in these projects as well:

* https://metacpan.org/pod/Carmel
* https://metacpan.org/pod/Carton

Carmel is the successor of Carton, which is a tool for bundling 
dependencies with your application.


Best regards,
Jan Henning Thorsen


On Monday, February 22, 2016 at 2:44:57 PM UTC+1, 
mouleeshwara...@jothisoftware.com wrote:
>
>  Hello everyone, i had completely developed an application in perl with 
> mojolicious framework. since i am new to perl and its frameworks i don't 
> know how to *upload the project to the server* or* hosting the project 
> online*. if it is possible to host the project with* apache server*. well 
> and good , please let me know how to do it! and also tell me know the *other 
> ways of deploying* the project online. Thanks in advanced.
>

-- 
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] How include HTML as HTML in templates?

2015-11-30 Thread Jan Henning Thorsen
You can also turn the string into a ByteStream object:

  # this... 
  use Mojo::ByteStream "b";
  my $x = b "hello!";
  $c->stash(x => $x);

  # or this...
  $c->stash(x => $c->b("Hello!"));


https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Plugin/DefaultHelpers.pm#b


On Monday, November 23, 2015 at 9:45:32 AM UTC+1, Helmut Wollmersdorfer 
wrote:
>
>
>
> Am Montag, 23. November 2015 09:22:04 UTC+1 schrieb Luc didry:
>>
>>
>> Simple: just use <%== instead of <%= (which XML escape the result). 
>>
>
> OMG, forgot this  feature.
>
> Thx
>
> Helmut Wollmersdorfer
>

-- 
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: Mock Useragent calls in controller for testing

2015-11-13 Thread Jan Henning Thorsen
What I do is that I have a "base url" that I can override. That way I can 
make the requests go the the local process instead of to the internet.

You can have a look here for an example

https://github.com/jhthorsen/mojolicious-plugin-stripepayment/blob/master/lib/Mojolicious/Plugin/StripePayment.pm#L300
https://github.com/jhthorsen/mojolicious-plugin-stripepayment/blob/master/lib/Mojolicious/Plugin/StripePayment.pm#L385
https://github.com/jhthorsen/mojolicious-plugin-stripepayment/blob/master/t/stripe-charge.t

So when I register the plugin with "mocked" set to a true value, I change 
the "base_url" and pass all the requests my application and render the 
response with some additional routes created by the plugin.


On Thursday, November 12, 2015 at 1:17:35 AM UTC+1, William Wheeler wrote:
>
> I have a controller method which makes calls using $controller->delay to 
> another service.  I want to mock the response from these services so that 
> unit tests can still run without needing to connect to the other services. 
>  I've found a way by subscribing to the controller and the tx like so 
> $t->app()->ua()->on(start => sub {
>my ($ua, $tx) = @_;
>$tx->on(finish => sub{
>my $tx = shift;
>my $mock_res = Mojo::Message::Response->new();
>$mock_res->code(200);
>$mock_res->body('{"foo":"bar"}');
>$tx->res($mock_res);
>return;
>}
> });
>
> This does what I want but will still make the call out to the service.  Is 
> there a way to do something similar before the call gets made? Am I 
> thinking about this wrong? 
>
> 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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Singleton(s) and workers

2015-10-31 Thread Jan Henning Thorsen
Not sure what other results you might expect in a "prefork-environment", vs 
a single process.

On Monday, October 26, 2015 at 2:11:03 PM UTC+1, Boris Baldassari wrote:
>
> Hi all, 
>
> I finally got it working using File::ChangeNofity instead of 
> AnyEvent::Filesys::Notify, since it needs less dependencies and is good 
> enough for my needs. The idea of watching file changes was a really good 
> one, thanks again to Jan. 
>
> I still have one question to finish that: how could I test the 
> thread-safe behaviour? When running the tests (e.g. with myapp.pl test) 
> I make the assumption that Mojolicious is using something like morbo, 
> that is a single-threaded version of the application. Is there any means 
> to either: 
> * test the app in a preforked context (by launching hypno or prefork 
> server instead of a dev one) 
> * tell the test run to use an existing web site instead of the current 
> dev? 
>
> The last option would be the best, since it would really test the app in 
> a production context. But I could not find anywhere a way to tell the 
> test agent to look for a specific url (where my dev is hosted)... Is 
> there one? 
>
> Thanks, 
>
> -- 
> Boris 
>
>
>
> Le 23/10/2015 21:10, Boris Baldassari a écrit : 
> > Le 23/10/2015 12:22, Jan Henning Thorsen a écrit : 
> >> If it's not critical that changes in the file is visible instantly, you 
> >> could do something like this: 
> > It's not critical if the changes appears after a few seconds, so the 
> > idea is good, thank you -- and thanks for the code, which is helpful. 
> > 
> > 
> >> This will make the application read the file every 30 second and update 
> >> the "dashboard" config parameter. The code could also check if the 
> >> timestamp of the json file has changed and simply not read the content 
> >> if mtime is the same. 
> > I didn't like the idea of checking a mtime each time I did a request 
> > to the data -- which would be almost each time a user displays a page. 
> > Feels like loosing the efficiency of having everything in memory. 
> > 
> >> Another idea is to use AnyEvent::Filesys::Notify instead of the 
> >> recurring timer. (There might be similar solutions, but that was the 
> one 
> >> that came to mind first) 
> > Oh, I didn't know of that one. And really like it, for it respects the 
> > data/file paradigm for understandability. 
> > It may indeed be the best solution, among other things for 
> > portability. I will give it a try, and report back to the list next 
> week. 
> > Really good advice, thanks! 
> > 
> > 
> >> About hot reloading: If you are running both the workers and manager as 
> >> the same user, then the worker can do initiate hot reload using "kill 
> >> USR2 => getppid". 
> > Yes, smart! Still GTK (Good To Know (tm)). 
> > 
> > Thanks again, 
> > 
> > 
> > -- 
> > Boris 
> > 
> >> 
> >> 
> >> On Friday, October 23, 2015 at 10:10:46 AM UTC+2, Boris Baldassari 
> >> wrote: 
> >> 
> >> Hi Jan, 
> >> 
> >> The app is a kind of dashboard for sw project assessment, and it 
> >> maintains a set of data on software projects (metrics, 
> >> meta-information, etc.). There is an analysis (i.e. an update on 
> >> this data) started every day, plus occasional changes on user's 
> >> initiative. So the information is not changing *heavily*. 
> >> 
> >> My point is I *want* to maintain the data on disk as json files, 
> >> because I believe that a data-based process (i.e. having a process 
> >> transforming data between known states) is easier to read and 
> >> understand for users and maintainers. 
> >> After giving some thoughts to memcache/redis/etc. I realise I would 
> >> have to synchronise the data on disk every time it changes, which 
> is 
> >> quite cumbersome and not very reliable. 
> >> 
> >> Maybe hot reloading hypnotoad would be the way to go. How could I 
> do 
> >> that from the code itself, apart from executing shell commands? 
> >> 
> >> Another option would be to load the data at startup, and write it 
> >> down to the disk on shutdown (through a END sub). Not sure about 
> the 
> >> reliability of such a solution though. 
> >> 
> >> Any idea would be welcome. Thanks! 
> >> 
> >> -- 
> >> Boris 
> >> 
> >> 
> >> 
>

[Mojolicious] Re: Architectural question - Best practice?

2015-10-02 Thread Jan Henning Thorsen
In this case, I don't think I would go for a lite app, but rather create 
controller classes and a full app. You can then do things like:

package MyApp::Controller::User;
use Mojo::Base "Mojolicious::Controller";
sub some_action {
  my $c = shift;
  $c->render(text => "both apps");
}

package MyBackOfficeApp::Controller::User;
use Mojo::Base "MyApp::Controller::User";
sub more_stuff {
  my $c = shift;
  $c->render(text => "just in this app");
}

That way, you have isolated the code, which means that it is impossible to 
access "more_stuff()" from the MyApp.


On Thursday, October 1, 2015 at 2:23:02 PM UTC+2, Pablo IaCo wrote:
>
> Thanks Richard, that was something that I started to work later after 
> creating this post in order to gain some time. I've started to create my 
> modules as usual and include them...but I was unaware of mojos plugins. 
> That's a reflection of how much I've researched the site, that's something 
> that I need to improve.
>
> Much appreciated your response!
>
>
> On Thursday, October 1, 2015 at 9:18:57 AM UTC-3, Richard Sugg wrote:
>>
>> Mojolicious lets you write plugins for sharing code across controllers, 
>> or in the case of a mojo lite app, callbacks.
>>
>> Another solution is to just write plain old perl modules and include 
>> them. This is the approach I have taken -- sometimes I write functionality 
>> in Mojolicious plugins, then realize I need it in something unrelated, so I 
>> end up refactoring to a standard perl module, and include it in my 
>> mojolicious app. In general, I try to make my controllers extremely lite -- 
>> check the input parameters, call out to a mojo plugin or perl module to 
>> accomplish what is asked, and in the controller, return an appropriate 
>> response.
>>
>> On Wednesday, September 30, 2015 at 5:05:22 PM UTC-4, Pablo IaCo wrote:
>>>
>>> Hi Folks,
>>>
>>> I just wanted to share with you something that I'm trying to figure out.
>>>
>>> I'm currently building a small App for my own and it's build like follows
>>> 1) The App itself (with login and stuff)
>>> 2) A Back-Office (with login and more stuff and creation of information 
>>> for the main app)
>>>
>>> The question that I want to ask is, that currently I've started to build 
>>> the main application.pl file, with Mojolicious::Lite, with most of the 
>>> routes and stuff inside of it.
>>>
>>> But my question is, how should I approach to develop the back office? I 
>>> mean, shall I write the whole thing INSIDE the main application.pl or 
>>> is it better to create a sepparated application just to handle the back 
>>> office.
>>>
>>> My concern with the second approach is, how to handle those packages 
>>> that are common to each part? 
>>>
>>> Thanks in advance and I'm just doing my first steps into a bigger 
>>> mojolicious app, so that's why I created this post
>>> Regards
>>> Pablo
>>>
>>

-- 
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: Are you using Mojolicious::Plugin::AssetPack and assets in memory?

2015-09-25 Thread Jan Henning Thorsen
Update: 0.65 is released, without in-memory support.

If you want temp asset support, then we could /maybe/ work out some 
temp-dir files, but this will only be done on request.

Changes for 0.65:

0.65 2015-09-25T16:55:49+0200
 - Add EXPERIMENTAL fixed mapping between moniker to packed files #64
 - Add EXPERIMENTAL test_app() to ensure all assets are created
 - Change headers() into a method
 - Change out_dir() into a read-only method, as documented
 - Remove EXPERIMENTAL support for reloader.js
 - Remove deprecated preprocessor() method
 - Remove support for in-memory assets #64
 - Fix memory leak

I will hopefully make a standalone reloader module. Not sure yet. The 
original implementation was one ugly hack, so I'm glad I took that out.


On Tuesday, September 22, 2015 at 3:42:43 PM UTC+2, Jan Henning Thorsen 
wrote:
>
> Hey,
>
> I want to remove the support for "in memory assets" 
> from Mojolicious::Plugin::AssetPack.
>
> The reason I implemented it in the first place was to support building 
> assets for an application that was installed in a read-only directory. This 
> again meant that if the checksum logic or something else changed, the 
> application would fail to start up since it has nowhere to save the files.
>
> My plan forward now is that instead of supporting this, I want to be able 
> to freeze the asset name to output files so the process logic won't be 
> called, but using the mapping produced while developing the application 
> instead.
>
> This change will also remove a lot of lines of code and release a 
> complexity I don't really want to maintain.
>
>
> So... Is anyone using "in memory assets" functionality? If so, how long 
> before I can remove it? I do think no-one is actually aware of this 
> functionality, so I might just remove it without a warning even if it's not 
> documented as EXPERIMENTAL.
>
>
>
> Best regards,
> Jan Henning Thorsen, aka batman
>

-- 
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] Are you using Mojolicious::Plugin::AssetPack and assets in memory?

2015-09-22 Thread Jan Henning Thorsen
Hey,

I want to remove the support for "in memory assets" 
from Mojolicious::Plugin::AssetPack.

The reason I implemented it in the first place was to support building 
assets for an application that was installed in a read-only directory. This 
again meant that if the checksum logic or something else changed, the 
application would fail to start up since it has nowhere to save the files.

My plan forward now is that instead of supporting this, I want to be able 
to freeze the asset name to output files so the process logic won't be 
called, but using the mapping produced while developing the application 
instead.

This change will also remove a lot of lines of code and release a 
complexity I don't really want to maintain.


So... Is anyone using "in memory assets" functionality? If so, how long 
before I can remove it? I do think no-one is actually aware of this 
functionality, so I might just remove it without a warning even if it's not 
documented as EXPERIMENTAL.



Best regards,
Jan Henning Thorsen, aka batman

-- 
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: hypnotoad vs uwsgi

2015-09-11 Thread Jan Henning Thorsen
I don't see how uwsgi would give you anything extra. Can you explain?

When it comes to number of connections, you should make your application 
non-blocking. At work I went from 80+ workers to 8 after I changed from 
blocking code to non-blocking code. The reason is that Mojo::IOLoop is able 
to multiplex the database queries and the other I/O operations.

Hypnotoad also give you the ability to hot reload -- meaning you have zero 
downtime when reloading the application between upgrades.


On Thursday, September 10, 2015 at 3:24:37 PM UTC+2, Matija Papec wrote:
>
>
> I'm considering these two options in terms of scalability, so which should 
> I consider when number of connections and not the speed is an issue?
>
> Tia
>
>
>

-- 
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] Using hypnotoad with upstart

2015-09-10 Thread Jan Henning Thorsen
If you run hypnotoad in the foreground, you can't do hot reload. I would 
say you're better off with prefork unless you need hot reload:

   $ yourapp.pl prefork -h

If you know of an "init script to upstart adapter", you could use 
Toadfarm https://metacpan.org/pod/Toadfarm#SYNOPSIS which provide the same 
interface as a init script.


On Tuesday, August 18, 2015 at 10:57:20 PM UTC+2, Carson Anderson wrote:
>
> Super delayed response here but you need to add the "-f" after hypnotoad 
> not after your script.
>
> hypnotoad -f  /data/web/mojo/router
>
>
> On Wednesday, February 5, 2014 at 4:22:04 PM UTC-7, Stefan wrote:
>>
>> Can someone provide a sample upstart conf file for 
>> starting/stopping/restarting hypnotoad?
>>
>> This isn't doing it.  (I tried with and without -f)
>>
>> description "mojo upstart job"
>>
>> start on runlevel [2345]
>> stop on runlevel [!2345]
>>
>> pre-start exec hypnotoad /data/web/mojo/router -f
>> pre-stop exec hypnotoad /data/web/mojo/router -f
>> post-stop exec hypnotoad /data/web/mojo/router -s
>>
>>
>> On Monday, May 14, 2012 6:44:10 AM UTC-5, koorchik wrote:
>>>
>>> -f, --foreground  Keep manager process in foreground. 
>>>
>>> 2012/5/14 Konstantin Cherkasoff : 
>>> > Hi All! 
>>> > Can I get hypnotoad to NOT become a daemon and stay connected with 
>>> parent 
>>> > process? 
>>> > It is useful when running under superdaemon control like upstart. 
>>>
>>> -- 
>>> Viktor Turskyi 
>>> http://webbylab.com 
>>> http://koorchik.blogspot.com 
>>>
>>

-- 
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: Mojo::IOLoop and epoll bug?

2015-09-10 Thread Jan Henning Thorsen
I cannot replicate the issue I "fixed" in Mojo::Redis2 without EV installed.


On Thursday, September 10, 2015 at 2:54:39 PM UTC+2, sri wrote:
>
> Also confirmed on OS X with kqueue.
>>
>
> Actually i was wrong, because now i can't replicate the problem anymore.
>
> --
> 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] Re: Mojo::IOLoop and epoll bug?

2015-09-10 Thread Jan Henning Thorsen
I've experienced the same 
issue: https://github.com/jhthorsen/mojo-redis2/issues/12

I think this is an EV issue, which can't be fixed by Mojolicious. I could 
be wrong though.


On Wednesday, September 9, 2015 at 4:42:59 PM UTC+2, Хозов Андрей wrote:
>
> I have a strange behavior Mojo::IOLoop::Client while connect to localhost 
> when it resolves in two addresses.
>
> *$ host localhost*
> localhost has address 127.0.0.1
> localhost has IPv6 address ::1
> *$*
>
> When using EV via select or poll or Mojo::Reactor::Poll all is ok. But 
> when using EV via epoll I get the error "connect timeout".
>
> *$ LIBEV_FLAGS=2 strace perl -MMojo::IOLoop -le 
> 'Mojo::IOLoop->client({address => "localhost", port => 27017}, sub { my 
> ($l, $err, $stream) = @_; warn $err;  Mojo::IOLoop->stop }); 
> Mojo::IOLoop->start'*
> socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP) = 3
> ...
> connect(3, {sa_family=AF_INET6, sin6_port=htons(27017), 
> inet_pton(AF_INET6, "::1", _addr), sin6_flowinfo=0, sin6_scope_id=0}, 
> 28) = -1 EINPROGRESS (Operation now in progress)
> fcntl(3, F_GETFL)   = 0x802 (flags O_RDWR|O_NONBLOCK)
> *poll([{fd=5, events=POLLIN}, {fd=3, events=POLLOUT}], 2, 9996) = 1 
> ([{fd=3, revents=POLLOUT|POLLERR|POLLHUP}])*
> getsockopt(3, SOL_SOCKET, SO_ERROR, [111], [4]) = 0
> socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
> ...
> dup2(4, 3)  = 3
> close(4)= 0
> fcntl(3, F_GETFL)   = 0x2 (flags O_RDWR)
> fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK)= 0
> connect(3, {sa_family=AF_INET, sin_port=htons(27017), 
> sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in 
> progress)
> *poll([{fd=5, events=POLLIN}, {fd=3, events=POLLOUT}], 2, 9996) = 1 
> ([{fd=3, revents=POLLOUT}])*
> getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
> connect(3, {sa_family=AF_INET, sin_port=htons(27017), 
> sin_addr=inet_addr("127.0.0.1")}, 16) = 0
> getpeername(3, {sa_family=AF_INET, sin_port=htons(27017), 
> sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
> setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 0
> ...
>
> *$ LIBEV_FLAGS=4 strace perl -MMojo::IOLoop -le 
> 'Mojo::IOLoop->client({address => "localhost", port => 27017}, sub { my 
> ($l, $err, $stream) = @_; warn $err if $err;  Mojo::IOLoop->stop }); 
> Mojo::IOLoop->start'*
> socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP) = 3
> ...
> connect(3, {sa_family=AF_INET6, sin6_port=htons(27017), 
> inet_pton(AF_INET6, "::1", _addr), sin6_flowinfo=0, sin6_scope_id=0}, 
> 28) = -1 EINPROGRESS (Operation now in progress)
> fcntl(3, F_GETFL)   = 0x802 (flags O_RDWR|O_NONBLOCK)
> epoll_ctl(5, EPOLL_CTL_ADD, 3, {EPOLLOUT, {u32=3, u64=4294967299}}) = 0
> *epoll_wait(5, {{EPOLLOUT|EPOLLERR|EPOLLHUP, {u32=3, u64=4294967299}}}, 
> 64, 9996) = 1*
> epoll_ctl(5, EPOLL_CTL_MOD, 3, {EPOLLOUT, {u32=3, u64=4294967299}}) = 0
> getsockopt(3, SOL_SOCKET, SO_ERROR, [111], [4]) = 0
> socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
> ...
> dup2(4, 3)  = 3
> close(4)= 0
> fcntl(3, F_GETFL)   = 0x2 (flags O_RDWR)
> fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK)= 0
> connect(3, {sa_family=AF_INET, sin_port=htons(27017), 
> sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in 
> progress)
> *epoll_wait(5, {}, 64, 9995) = 0*
> write(2, "Connect timeout at -e line 1,  line 1,  line 2231.
> ...
>
>
> I see that the second time epoll_wait is not monitoring the descriptor(3) 
> and therefore a connect event is missing.
> Can you explain me this behavior?
>
>
> -- 
> Andrey Khozov
>

-- 
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: Terminating mojolicious application

2015-07-31 Thread Jan Henning Thorsen
It sounds like you're seeking the wrong solution, but it's impossible to 
tell for sure without more detailed information.

If you're on the right track, then maybe you need END {...}, but there's no 
guaranties for any of these solutions to actually work.


On Friday, July 31, 2015 at 5:51:41 PM UTC+2, Хозов Андрей wrote:

 What is the best way to see that Mojolicious app is terminated 
 (application running via hypnotoad/morbo)? This can be useful when you need 
 to aggregate some data in memory and periodically flushing the data in the 
 persistent store.

 Should I use sub DESTROY inside the app for this? Or I need just subscribe 
 to the event finish in Mojo::IOLoop?  Are there any ways to do this?


 -- 
 Andrey Khozov


-- 
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: Terminating mojolicious application

2015-07-31 Thread Jan Henning Thorsen
None of the solutions you're looking for are reliable.

I would suggest logging each request when they happen. I'm logging all 
requests to a plain access log file, 
using https://metacpan.org/pod/Toadfarm::Plugin::AccessLog, but you can 
also use https://metacpan.org/pod/Mojolicious::Plugin::AccessLog

This should be very fast, especially if you log to a file on a ram disk.

Other option could be syslog to localhost. It *should be* very reliable, 
even if UDP by nature is not...


On Friday, July 31, 2015 at 6:41:11 PM UTC+2, Хозов Андрей wrote:

 For example you need to process many events and store its in database. 1 
 http request -- 1 event. In action you can store events to buffer (e.g. 
 attribute of
 mojolicious application). And you have recurring timer to save data into 
 database via bulk request. All is OK until worker with application is 
 restarted. Some
 ​​events will be lost in this case. So I think you need to catch 
 terminating application event.

 There is another option to catch TERM and QUIT signals. But it doesn't 
 look too reliable.


 On Fri, Jul 31, 2015 at 9:27 PM, Jan Henning Thorsen 
 jan.henn...@thorsen.pm wrote:

 It sounds like you're seeking the wrong solution, but it's impossible to 
 tell for sure without more detailed information.

 If you're on the right track, then maybe you need END {...}, but there's 
 no guaranties for any of these solutions to actually work.


 On Friday, July 31, 2015 at 5:51:41 PM UTC+2, Хозов Андрей wrote:

 What is the best way to see that Mojolicious app is terminated 
 (application running via hypnotoad/morbo)? This can be useful when you need 
 to aggregate some data in memory and periodically flushing the data in the 
 persistent store.

 Should I use sub DESTROY inside the app for this? Or I need just 
 subscribe to the event finish in Mojo::IOLoop?  Are there any ways to do 
 this?


 -- 
 Andrey Khozov




 -- 
 Andrey Khozov


-- 
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] Form validation and redirects

2015-07-28 Thread Jan Henning Thorsen
Sorry about the bad chose of words. The only reason is not correct. There 
are always exceptions, but in your case it's still valid:

1) You go to /login
2) You enter invalid login credentials and submit to /login
3) Mojolicious render /login
4) You enter correct login credentials and submit to /login
5) Mojolicious redirect you to /profile (or something else that's not 
/login)

Step #5 redirects and avoids the do you want to repost the form issue. 
You do not want to redirect on step #3, since that will make it much harder 
to prefill the form. In addition it adds extra load to the webserver, 
without adding any value. (At least I don't see any added value)

Here is another case:

1) You go to /profile, but you're not logged in
2) Mojolicious render the login form, with a hidden field with the original 
path /profile.
3) You enter correct login credentials and submit to /login
4) Mojolicious redirect you to /profile

Step #4 redirects and avoids the do you want to repost the form issue. 
You might also want to do a redirect on step #1 to 
/login?redirect_uri=/profile. This redirect will be done anyway, if you use 
third party login services.


On Tuesday, July 28, 2015 at 1:37:41 AM UTC+2, Stefan Adams wrote:


 On Fri, Jul 24, 2015 at 4:07 AM, Jan Henning Thorsen 
 jan.henn...@thorsen.pm wrote:

 The only reason to do a redirect is when you want to avoid the do you 
 want to repost the form when someone click the refresh wheel or F5.


 Or if you care about the URL.  Is this a stupid reason?  If I find myself 
 doing redirects instead of renders for this reason too frequently am I 
 doing it wrong?  That is, do I really need my users seeing the URL as 
 /login as opposed to /profile if they aren't logged in?  Or, is this off 
 topic from form validation?



-- 
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] Automatically extend user session expiration when active websocket connection only

2015-07-28 Thread Jan Henning Thorsen
Finally I got the new computer set up :-)

Anyway... Here is the code: https://ssl.thorsen.pm/paste/4313bc059551


On Saturday, July 25, 2015 at 7:06:49 AM UTC+2, Александр Грошев wrote:

 I will wait. 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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Automatically extend user session expiration when active websocket connection only

2015-07-24 Thread Jan Henning Thorsen
I suppose you can also transfer a new version of the session cookie over the 
websocket, and then use document.cookie do write this new verified cookie on 
the client side.

-- 
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: Form validation and redirects

2015-07-24 Thread Jan Henning Thorsen
variant, template or if/else inside the template.

You decide what is best.

-- 
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: set a link to http from https

2015-06-17 Thread Jan Henning Thorsen
Out of curiosity, why don't you use HTTPS everywhere?

On Sunday, June 14, 2015 at 2:07:13 PM UTC+2, Ivan Kolisnyk wrote:

 Hello everybody.
 I'm developping CMS for web on Mojolicious. I have a problem with setting 
 up a link from admin part under https protocol to client part under http 
 protocol.
 And inversely, from client part under http protocol to admin part under 
 https protocol.
 Thanks for the answer.


-- 
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] Get at name of current template?

2015-06-03 Thread Jan Henning Thorsen
While developing, you can see which templates are rendered on screen, with 
either:

$ morbo script/yourapp.pl
$ MOJO_LOG_LEVEL=debug perl script/yourapp.pl daemon

You will then see something like this in the log:

[Wed Jun  3 10:39:22 2015] [debug] Rendering template index.html.ep
[Wed Jun  3 10:39:22 2015] [debug] Rendering template partials/nav.html.ep
[Wed Jun  3 10:39:22 2015] [debug] Rendering template 
partials/footer.html.ep
[Wed Jun  3 10:39:22 2015] [debug] GET /

Note that if nothing appears to STDERR, then it's probably because you have 
./log directory.

On Monday, May 18, 2015 at 11:45:42 AM UTC+2, Juergen Nickelsen wrote:

 On 14.05.2015 04:11, Justin Hawkins wrote: 

  for a while I have been trying to get at the name of the template that 
  is just being rendered, to use it in the layout. 
  
  I can’t answer your question directly, but this requirement sounds like 
  a bit of a code smell. What are you trying to accomplish? 

 Oh, I understand your suspicion. What I want to have is just an 
 informational comment in the rendered page that says which template has 
 rendered that page, like this: 

 !-- template v_m_s/domains.html.ep -- 

 As I said, I am a novice with Mojolicious and serious web 
 applications, plus my application is (at this stage of development) 
 akind of twisty little maze of pages, of which some are, while not 
 actually redundant, relatively similar. At some point I was actually 
 wondering which template had rendered the page I was looking at, hence 
 that idea. 

 I could easily put that line by hand into each template to achieve the 
 same effent (or even devise a scheme to have that done automatically), 
 but as Mojolicious is great at avoiding boilerplate, I thought it should 
 be able to come up with a generic solution. 

 It is certainly not something that will be needed for production code. 

 Regards, Juergen. 

 -- 
 juergen.nickel...@fu-berlin.de Tel +49.30.838-50740 Fax -450740 
 Zentraleinrichtung fuer Datenverarbeitung, Central Systems (Unix) 
 Freie Universitaet Berlin, Fabeckstrasse 32, 14195 Berlin, DE 


-- 
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 Preforking

2015-06-03 Thread Jan Henning Thorsen
I don't undestand what you're doing...

Why are you looking at the hypnotoad source code? Are you building a web 
application or a TCP/web server? Also, why are you looking at version 4.60. 
That is very old. Current version is 6.11.

If you're looking for how to make a web application, I would start out by 
looking at
* http://mojolicio.us
* http://mojolicio.us/perldoc
* http://mojolicio.us/perldoc/Mojolicious/Guides/Tutorial

If you're looking for informatin on how to run the application I would look 
at:
* http://mojolicio.us/perldoc/Mojolicious/Guides/Cookbook#DEPLOYMENT

If you're trying to write your own prefork server, then ... Why are you?


On Thursday, May 21, 2015 at 3:07:27 PM UTC+2, Priya Kanduru wrote:

 Hi team,

 I am newbie using mojilicious to develop an end-to-end tool to help user 
 in maintaining a Lab , like having privilages to provision devices,create 
 topologies,reserve topogies for their dev/test activites , generating 
 reports on usage of lab devices etc..,

 I am using MongoDB to ease info flow between UI and mojo. I have started 
 from a templete available 

 http://cpansearch.perl.org/src/MRAMBERG/Mojolicious-4.60/lib/Mojo/Server/Hypnotoad.pm
 .


 Just need some clarification as on executing  $prefork-run; command, 
 how many processes will be created? and how could I trace who is creating 
 which process and how many processes?




 Thanks in Advance,
 Priya


-- 
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: coro interface to Mojolicious

2015-05-13 Thread Jan Henning Thorsen
I haven't done this myself, but looks like sri drafted an idea which you 
might get some ideas from:

https://gist.github.com/kraih/6082061


On Friday, May 8, 2015 at 3:57:57 PM UTC+2, Eugene Toropov wrote:

 Greetings,

 Is there a working recipe to run mojo application in “coro mode” so that 
 it is run in coroutine similar to this - 
 http://search.cpan.org/~unera/Coro-Twiggy-0.03/lib/Coro/Twiggy.pm ?

 Cheers
 Eugene


-- 
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: is mojoconf 2015 really canceled?

2015-05-06 Thread Jan Henning Thorsen
I can confirm.

I updated http://www.mojoconf.com today.

On Tuesday, May 5, 2015 at 10:28:29 PM UTC+2, Karl Boehnker wrote:

 I saw this today: 
 http://blogs.perl.org/users/brian_d_foy/2015/05/mojoconf-is-cancelled-im-scrambling-to-do-something-anyway.html

 Can anyone else confirm or deny?


-- 
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] change from morbo to hypnotoad for multiple domains

2015-04-30 Thread Jan Henning Thorsen
I wonder what kind of output you expect...

So when I start the test apps with log level debug, I see this 
in test1/log/development.log
[Thu Apr 30 23:09:30 2015] [debug] Routing to a callback
[Thu Apr 30 23:09:30 2015] [debug] Rendering template index.html.ep
[Thu Apr 30 23:09:30 2015] [debug] 200 OK (0.001527s, 654.879/s)

...and this is what starter.pl logs:
[Thu Apr 30 23:09:30 2015] [debug] GET /
[Thu Apr 30 23:09:30 2015] [debug] Routing to application Test1

So... maybe you don't see anything, because hypnotoad (which toadfarm use 
to run the application) sets the log level to info...? The reason why the 
log level is info and not debug under hypnotoad is because it will 
MOJO_MODE=production, unless you have set something custom, which again 
affect the log level:
* https://metacpan.org/pod/Mojolicious#mode
* https://metacpan.org/pod/Mojo::Server::Hypnotoad#DESCRIPTION


Btw (not related): I see that you start the script with sudo and listen 
to port 80. I suggest you have a look at these resources regarding this:
* 
https://groups.google.com/forum/?utm_source=digestutm_medium=email#!topic/mojolicious/M_xB_Vy7e8g
* 
https://metacpan.org/pod/Toadfarm::Manual::RunningToadfarm#Listen-to-standard-HTTP-ports
* https://metacpan.org/pod/Toadfarm::Manual::DSL#run_as


On Thursday, April 30, 2015 at 4:45:39 PM UTC+2, mjb152 wrote:

 Jan - I'm currently running with 2 apps mounted on different domains, all 
 works well ... except I get absolutely no logging output.
 I expected the log files in each app to be written to as normal , unless I 
 override it.  
 If I start each app with morbo, then logging works,   but if I use 
 Toadfarm with *sudo ./starter.pl http://starter.pl start * , then I get 
 no output.  Can you advise why ?
 I've built this very basic example to demonstrate the issue I'm having.
 https://github.com/mjb152/toadtest

 On Mon, Apr 27, 2015 at 11:29 AM, mjb152 martin.bo...@gmail.com wrote:

 regex...works perfectly, thx.

 I'm not using logging(), I'll play around some more with different 
 configs, but the config is as basic as the code I posted above.

 -- 
 You received this message because you are subscribed to a topic in the 
 Google Groups Mojolicious group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/mojolicious/WFh3C3elp9Y/unsubscribe.
 To unsubscribe from this group and all its topics, 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.




-- 
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] change from morbo to hypnotoad for multiple domains

2015-04-27 Thread Jan Henning Thorsen
Pickup domain1 and domain2:

Oh! I've forgot to document that the matching headers can also take a 
regex. I will fix that later today.

So... you can either of these works:

# use a regex
mount test1 = {Host = qr/domain\d+\.com/};
# ...or mount the same app twice
mount test1 = {Host = domain1.com};
mount test1 = {Host = domain2.com};

I don't know why logging doesn't work. It should be something wrong in 
test1/test2, as long as you don't use logging 
https://metacpan.org/pod/Toadfarm::Manual::DSL#logging(). (But I'm 
guessing you *don't* use logging(), since it's not part of your example 
code). The only way for Toadfarm to take over logging from test1/test2 is 
if you have specified logging {combined=1}. See 
also https://metacpan.org/source/JHTHORSEN/Toadfarm-0.55/lib/Toadfarm.pm#L286 
and https://metacpan.org/pod/Toadfarm::Manual::DSL#logging


On Monday, April 27, 2015 at 11:26:30 AM UTC+2, mjb152 wrote:

 this code works without nginx, and I have 2 questions.

 I'd like to mount the first app to pickup both domain1.com , and 
 www.domain1.com , currently it doesn't. Is there a way to achieve that ?
 Secondly, no logging is being output to the normal log/development.log (in 
 each app), nor does it go to /var/log/toadfarm , I could combine them both 
 into 1 log, but I'd like to keep them separate if possible ?


 *mount /home/mojouser/apps/test1/script/test1 = { Host = domain1.com 
 http://domain1.com,   };*
 *mount /home/mojouser/apps/test2/script/test2 = { Host = domain2.com 
 http://domain2.com, };*

 *start [http://*:80];*


-- 
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] [Security] Mojolicious 6.10 (user/group assignment)

2015-04-27 Thread Jan Henning Thorsen
These are the issues I know of:

* If you only specify user, then the workers will run with the groups of 
root.
* If you specify a group, then the workers will only run as that group 
and not all the secondary groups of the user you specified.


On Monday, April 27, 2015 at 10:39:57 AM UTC+2, Ludwig Nussel wrote:

 sri schrieb: 
  TLDR: The group assignment fix in Mojolicious 5.53 did not work out, 
  and you should now be using Mojolicious::Plugin::SetUserGroup. 
  
  Yesterday we've been made aware that the user/group assignment feature 
  of all our built-in web servers was still not working correctly. This 

 What was the problem exactly? 

 cu 
 Ludwig 

 -- 
   (o_   Ludwig Nussel 
   //\ 
   V_/_  http://www.suse.de/ 
 SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Jennifer 
 Guild, Dilip Upmanyu, Graham Norton, HRB 21284 (AG Nürnberg) 
 Maxfeldstraße 5; 90409 Nürnberg; Germany 


-- 
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] change from morbo to hypnotoad for multiple domains

2015-04-26 Thread Jan Henning Thorsen
The config below is not possible. You can't merge two apps at the same 
mount_point, and you don't need Host if you're not trying to filter on 
the value.

mount /home/mojouser/apps/test1/script/test1= {mount_point 
= /};
mount /home/mojouser/apps/test2/script/test2= {mount_point 
= /test2};

The config above will mount all the routes inside test1 directly on the 
root (/) while test2 is available under /test2.

Currently I have no idea how to implement merging of routes from two 
applications, and I would be very cautious about implementing it even if I 
knew how. The reason is that I think it will be very confusing.


On Sunday, April 26, 2015 at 2:33:39 PM UTC+2, mjb152 wrote:

 0.52 works well, thanks !


 https://metacpan.org/pod/distribution/Toadfarm/lib/Toadfarm/Manual/Intro.pod 
   has a typo,  in any trick you like form the Perl toolbox.

 currently I'm just testing with 1 IP address, no domains have been 
 transferred in yet, how can I test with 2 apps mounted and just adjusting 
 the url ?

 mount /home/mojouser/apps/test1/script/test1= {Host = 
 46.101.2.191:8080, mount_point = /};
 mount /home/mojouser/apps/test2/script/test2= {Host = 
 46.101.2.191:8080, mount_point = /};


-- 
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] change from morbo to hypnotoad for multiple domains

2015-04-26 Thread Jan Henning Thorsen
Please don't say code you haven't run doesn't work or doesn't work the way you 
expect.

It makes it impossible to help.


 On 26. apr. 2015, at 17.22, mjb152 martin.bo...@gmail.com wrote:
 
 that was a bad example from my side, I'll play with the config below and 
 transfer in another domain to test it ..
 
 mount /home/mojouser/apps/test1/script/test1 = {  Host = domain1.com, };
 mount /home/mojouser/apps/test1/script/test2 = {  Host = domain2.com, };
  
 -- 
 You received this message because you are subscribed to a topic in the Google 
 Groups Mojolicious group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/mojolicious/WFh3C3elp9Y/unsubscribe.
 To unsubscribe from this group and all its topics, 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.

-- 
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] change from morbo to hypnotoad for multiple domains

2015-04-25 Thread Jan Henning Thorsen
Thanks Stefan!

mjb152: Good timing, since I just released a much simpler Toadfarm 
yesterday :)

I think it will fit your needs perfectly. Please let me know if there's 
anything you think is complicated or not very intuitive about it.

https://metacpan.org/pod/Toadfarm
https://metacpan.org/pod/distribution/Toadfarm/lib/Toadfarm/Manual/BehindReverseProxy.pod

There's more documentation as well:
https://metacpan.org/pod/Toadfarm#DOCUMENTATION-INDEX


On Saturday, April 25, 2015 at 2:59:00 PM UTC+2, Stefan Adams wrote:


 On Apr 25, 2015 5:28 AM, mjb152 martin.bo...@gmail.com wrote:
 
  now that looks exactly what I'm after, wildcards for subdomains as well 
 !!

 Moreover, check out Toadfarm.
  

-- 
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] change from morbo to hypnotoad for multiple domains

2015-04-25 Thread Jan Henning Thorsen
I'm guessing sudo doesn't inherit the PATH from your user, so it doesn't 
find hypnotoad. I guess I could make Toadfarm a bit more clever when it 
comes to finding hypnotoad, but I'm making dinner now so the 
improvement won't be available until tomorrow.

Anyhow, try running sudo -E instead or manipulate $ENV{PATH} inside 
webfarm, like this:

  $ENV{PATH} = 
/home/mojouser/perl5/perlbrew/perls/perl-5.20.2/bin:$ENV{PATH};

I would very much appreciate if you made an issue on github 
https://github.com/jhthorsen/toadfarm/issues, but I will try to look into 
this either way.


On Saturday, April 25, 2015 at 6:29:38 PM UTC+2, mjb152 wrote:

 Jan - I'm playing with this now, but hitting an initial problem. 

 I generate 2 apps, with: -

 mojo generate app Test1
 mojo generate app Test2

 I then edit both the scripts  (test1/script/test1 
  and test2/script/test2), adding the following lines so they will start 
 nicely.

 *use FindBin;*
 *BEGIN { unshift @INC, $FindBin::Bin/../lib }*

 so now I have a directory called */home/mojouser/apps*  with 2 apps in 
 subdirectories *test1* and *test2*.
 If I type *morbo test1/script/test1  *then it works, same for test2.  all 
 good.

 If I create a file called webfarm, as below and start it, I get an error. 
  any ideas why ?

 webfarm
 #!/home/mojouser/perl5/perlbrew/perls/perl-5.20.2/bin/perl
 use Toadfarm -dsl;

 logging {
   combined = 1,
   file = /var/log/toadfarm/app.log,
   level= info,
 };

 mount /home/mojouser/apps/test1/script/test1= {Host = 
 46.101.2.191};
 mount /home/mojouser/apps/test2/script/test2= {Host = 
 46.101.2.191};

 plugin Toadfarm::Plugin::AccessLog;

 start; # need to be at the last line


 Error
 mojouser@ultron:~/apps$ sudo ./webfarm start
 Can't exec hypnotoad: No such file or directory at 
 /home/mojouser/perl5/perlbrew/perls/perl-5.20.2/lib/site_perl/5.20.2/Toadfarm/Command/
 start.pm line 44.
 Hypnotoad server failed to start. (72057594037927935)








-- 
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] app in a model

2015-04-20 Thread Jan Henning Thorsen
Many people != Mojolicious people. This is a very generic problem, 
where a higher level object pass itself to a lower level object. What I 
mean is that you build stuff from small components built on top of each 
other, and then you have this high level object on top which orchestrate 
the objects, passing on just enough information to make each of them work.

I will try to come up with a new example. Which of these two lines of code 
makes most sense to you?

  $user = $c-model-users-find({id = $c-param(user_id)});
  $user = $c-model-users-find($c);


Btw... I'm drifting. Your original question is very specific and not 
explaining why you want to pass $app to the model. Can you try to explain 
why you need to pass on $app to the model? Do you have an example 
usecase/piece of code where that makes most sense?


On Monday, April 20, 2015 at 11:10:20 AM UTC+2, Eugene Toropov wrote:

 Right, well, I hope Sebastian will have a moment to reply at some point if 
 it comes up so often and so many people were in the same state of mind :) 
 Or he did already? If so - would be great if someone could provide a link. 
 Thank you.

 Cheers
 Eugene

 On Apr 20, 2015, at 11:49 AM, Jan Henning Thorsen jan.henn...@thorsen.pm 
 wrote:

 It's so funny how this questions comes up over and over again. I even have 
 to battle it myself from time to time, even when I know how stupid (Sorry 
 for using stupid, but I think I'm allowed as it reflects back on myself), 
 limiting, hard to get around later, ... it would be to pass some $app-like 
 object around to lower level models.

 Also, I probably know how your mind is set on your statement, and how you 
 probably just want to get confirmation instead of the answer I'm giving 
 you. Yes... Me and many before you have been in the same state of mind.

 So... I was hoping I could help you with my Mojo::Pg-new() example above, 
 but it seems like I have failed.

 I wish you the best of luck finding the right solution.

 I also apologize if I'm stepping on yours or anyone else's toes. That is 
 not my intention.


 On Monday, April 20, 2015 at 10:31:45 AM UTC+2, Eugene Toropov wrote:

 Hi Jan,

 Having to pass db = shift-model-db” in every model helper doesn’t 
 seem like invisible way ;) It would be really invisible if you had “use DB” 
 inside a model package and then “my $db = $DB::dbh” :) but then you’d have 
 to somehow pass app-config to DB. Also if you kept something in 
 app-config that model needs - would you pass it as another parameter to 
 every model you had? What if then you had app-cache (redis/memcached) ? 
 Another parameter to pass to every model again? I feel it doesn’t seem good 
 but can’t find any other way in Mojo to do it so thought someone had found 
 the solution...

 Cheers
 Eugene

 On Apr 20, 2015, at 11:18 AM, Jan Henning Thorsen jan.henn...@thorsen.pm 
 wrote:

 I pass on $db to every instance of a model in MCT: 
 https://github.com/mojoconf/MCT/blob/master/lib/MCT.pm#L33

 Just make a helper where the passing of $db (or any other common 
 argument) is invisible.

 The nice thing is that the model will need to know less. It will then be 
 easier to use for other things outside of your Mojo app. To flip the 
 question around. Which version ofof the code below makes most sense?

   my $app = Mojolicious-new;
   $db = Mojo::Pg-new(app = $app);
   $db = Mojo::Pg-new(app = $app-config-{db}{dsn});

 (I hope the version where $app is passed to new() looks weird...)


 On Monday, April 20, 2015 at 9:17:27 AM UTC+2, Eugene Toropov wrote:

 Hi Jan,

 Thanks for your reply. Don’t you think that passing app-db to every 
 model is not a good idea neither because model must know itself where data 
 are and how to fetch it and pass to controller? Also it’s simply 
 inconvenient to always have one (or even 2 - app-db and app-redis for 
 example) arguments passed to every model, no?

 Cheers
 Eugene

 On 20 Apr 2015, at 10:07, Jan Henning Thorsen jan.henn...@thorsen.pm 
 wrote:

 You don't. Passing $app or $c to a model is not a good idea. Reason for 
 this is that it makes it hard to reuse the models elsewhere. What you can 
 do, is passing data from $app when you construct your models, but I would 
 strongly advice against passing $app.


 On Friday, April 17, 2015 at 4:38:06 PM UTC+2, Eugene Toropov wrote:

 Greetings,

 In the following example how will you make MyApp::Model::Users have 
 access to app object (which is basically $self) that is necessary to use 
 app-db and app-config?


 http://mojolicio.us/perldoc/Mojolicious/Guides/Growing#WELL-STRUCTURED-APPLICATION

 package MyApp;use Mojo::Base 'Mojolicious';
 use MyApp::Model::Users;
 sub startup {
   my $self = shift;

   $self-secrets(['Mojolicious rocks']);
   $self-helper(users = sub { state $users = MyApp::Model::Users-new });

   my $r = $self-routes;

   $r-any('/' = sub {
 my $c = shift;

 my $user = $c-param('user') || '';
 my $pass = $c-param('pass') || '';
 return $c-render unless

Re: [Mojolicious] app in a model

2015-04-20 Thread Jan Henning Thorsen
I pass on $db to every instance of a model in 
MCT: https://github.com/mojoconf/MCT/blob/master/lib/MCT.pm#L33

Just make a helper where the passing of $db (or any other common argument) 
is invisible.

The nice thing is that the model will need to know less. It will then be 
easier to use for other things outside of your Mojo app. To flip the 
question around. Which version ofof the code below makes most sense?

  my $app = Mojolicious-new;
  $db = Mojo::Pg-new(app = $app);
  $db = Mojo::Pg-new(app = $app-config-{db}{dsn});

(I hope the version where $app is passed to new() looks weird...)


On Monday, April 20, 2015 at 9:17:27 AM UTC+2, Eugene Toropov wrote:

 Hi Jan,

 Thanks for your reply. Don’t you think that passing app-db to every model 
 is not a good idea neither because model must know itself where data are 
 and how to fetch it and pass to controller? Also it’s simply inconvenient 
 to always have one (or even 2 - app-db and app-redis for example) 
 arguments passed to every model, no?

 Cheers
 Eugene

 On 20 Apr 2015, at 10:07, Jan Henning Thorsen jan.henn...@thorsen.pm 
 wrote:

 You don't. Passing $app or $c to a model is not a good idea. Reason for 
 this is that it makes it hard to reuse the models elsewhere. What you can 
 do, is passing data from $app when you construct your models, but I would 
 strongly advice against passing $app.


 On Friday, April 17, 2015 at 4:38:06 PM UTC+2, Eugene Toropov wrote:

 Greetings,

 In the following example how will you make MyApp::Model::Users have 
 access to app object (which is basically $self) that is necessary to use 
 app-db and app-config?


 http://mojolicio.us/perldoc/Mojolicious/Guides/Growing#WELL-STRUCTURED-APPLICATION

 package MyApp;use Mojo::Base 'Mojolicious';
 use MyApp::Model::Users;
 sub startup {
   my $self = shift;

   $self-secrets(['Mojolicious rocks']);
   $self-helper(users = sub { state $users = MyApp::Model::Users-new });

   my $r = $self-routes;

   $r-any('/' = sub {
 my $c = shift;

 my $user = $c-param('user') || '';
 my $pass = $c-param('pass') || '';
 return $c-render unless $c-users-check($user, $pass);

 $c-session(user = $user);
 $c-flash(message = 'Thanks for logging in.');
 $c-redirect_to('protected');
   } = 'index');

   my $logged_in = $r-under(sub {
 my $c = shift;
 return 1 if $c-session('user');
 $c-redirect_to('index');
 return undef;
   });
   $logged_in-get('/protected');

   $r-get('/logout' = sub {
 my $c = shift;
 $c-session(expires = 1);
 $c-redirect_to('index');
   });}
 1;

 Cheers
 Eugene


 -- 
 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.




-- 
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] app in a model

2015-04-20 Thread Jan Henning Thorsen
It's so funny how this questions comes up over and over again. I even have 
to battle it myself from time to time, even when I know how stupid (Sorry 
for using stupid, but I think I'm allowed as it reflects back on myself), 
limiting, hard to get around later, ... it would be to pass some $app-like 
object around to lower level models.

Also, I probably know how your mind is set on your statement, and how you 
probably just want to get confirmation instead of the answer I'm giving 
you. Yes... Me and many before you have been in the same state of mind.

So... I was hoping I could help you with my Mojo::Pg-new() example above, 
but it seems like I have failed.

I wish you the best of luck finding the right solution.

I also apologize if I'm stepping on yours or anyone else's toes. That is 
not my intention.


On Monday, April 20, 2015 at 10:31:45 AM UTC+2, Eugene Toropov wrote:

 Hi Jan,

 Having to pass db = shift-model-db” in every model helper doesn’t seem 
 like invisible way ;) It would be really invisible if you had “use DB” 
 inside a model package and then “my $db = $DB::dbh” :) but then you’d have 
 to somehow pass app-config to DB. Also if you kept something in 
 app-config that model needs - would you pass it as another parameter to 
 every model you had? What if then you had app-cache (redis/memcached) ? 
 Another parameter to pass to every model again? I feel it doesn’t seem good 
 but can’t find any other way in Mojo to do it so thought someone had found 
 the solution...

 Cheers
 Eugene

 On Apr 20, 2015, at 11:18 AM, Jan Henning Thorsen jan.henn...@thorsen.pm 
 wrote:

 I pass on $db to every instance of a model in MCT: 
 https://github.com/mojoconf/MCT/blob/master/lib/MCT.pm#L33

 Just make a helper where the passing of $db (or any other common argument) 
 is invisible.

 The nice thing is that the model will need to know less. It will then be 
 easier to use for other things outside of your Mojo app. To flip the 
 question around. Which version ofof the code below makes most sense?

   my $app = Mojolicious-new;
   $db = Mojo::Pg-new(app = $app);
   $db = Mojo::Pg-new(app = $app-config-{db}{dsn});

 (I hope the version where $app is passed to new() looks weird...)


 On Monday, April 20, 2015 at 9:17:27 AM UTC+2, Eugene Toropov wrote:

 Hi Jan,

 Thanks for your reply. Don’t you think that passing app-db to every 
 model is not a good idea neither because model must know itself where data 
 are and how to fetch it and pass to controller? Also it’s simply 
 inconvenient to always have one (or even 2 - app-db and app-redis for 
 example) arguments passed to every model, no?

 Cheers
 Eugene

 On 20 Apr 2015, at 10:07, Jan Henning Thorsen jan.henn...@thorsen.pm 
 wrote:

 You don't. Passing $app or $c to a model is not a good idea. Reason for 
 this is that it makes it hard to reuse the models elsewhere. What you can 
 do, is passing data from $app when you construct your models, but I would 
 strongly advice against passing $app.


 On Friday, April 17, 2015 at 4:38:06 PM UTC+2, Eugene Toropov wrote:

 Greetings,

 In the following example how will you make MyApp::Model::Users have 
 access to app object (which is basically $self) that is necessary to use 
 app-db and app-config?


 http://mojolicio.us/perldoc/Mojolicious/Guides/Growing#WELL-STRUCTURED-APPLICATION

 package MyApp;use Mojo::Base 'Mojolicious';
 use MyApp::Model::Users;
 sub startup {
   my $self = shift;

   $self-secrets(['Mojolicious rocks']);
   $self-helper(users = sub { state $users = MyApp::Model::Users-new });

   my $r = $self-routes;

   $r-any('/' = sub {
 my $c = shift;

 my $user = $c-param('user') || '';
 my $pass = $c-param('pass') || '';
 return $c-render unless $c-users-check($user, $pass);

 $c-session(user = $user);
 $c-flash(message = 'Thanks for logging in.');
 $c-redirect_to('protected');
   } = 'index');

   my $logged_in = $r-under(sub {
 my $c = shift;
 return 1 if $c-session('user');
 $c-redirect_to('index');
 return undef;
   });
   $logged_in-get('/protected');

   $r-get('/logout' = sub {
 my $c = shift;
 $c-session(expires = 1);
 $c-redirect_to('index');
   });}
 1;

 Cheers
 Eugene


 -- 
 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.



 -- 
 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

Re: [Mojolicious] How to have a non-blocking 'any' route, which proxies multiple method requests?

2015-04-12 Thread Jan Henning Thorsen
Are you building a proxy..? Maybe you want to have a look at either of 
these:

https://metacpan.org/pod/Mojolicious::Plugin::Proxy
https://github.com/mojoconf/MCT/blob/master/lib/MCT/Plugin/ACT.pm

On Saturday, April 11, 2015 at 11:06:03 PM UTC+2, Charlie Brady wrote:


 On Sat, 11 Apr 2015, Dan Book wrote: 

  Perhaps this way: 
  my $tx = $ua-build_tx($method = ... normal get/post/etc args ...); 
  $ua-start($tx = sub { 
... 
  }); 

 Thanks. I'll try that. 

 Next problem is what needs to be done to read the request body and 
 transfer it to the ua. Would that happen automatigically if the req is 
 cloned? In this case, would Mojo buffer the request? Does anyone have a 
 gist which proxies a request without reading and caching the request body? 

 I've found this which deals with some of these issues: 

 https://larig.wordpress.com/2012/08/01/a-mini-proxy-via-mojolicious/ 

 Thanks all. 

  
  On Fri, Apr 10, 2015 at 4:01 PM, Charlie Brady  
  charlieb-m...@budge.apana.org.au wrote: 
  
   
   https://github.com/kraih/mojo/wiki/Blocking-vs-non-blocking-101 
   
   I see I can do this to have a non-blocking get handler: 
   
   ... 
 $self-render_later; 
   
 $self-ua-get('http://www.superhugepage.com/blah.html' = sub {}); 
   ... 
   
   But I don't understand how to use Mojo::UserAgent in an 'any' handler, 
   where method might be 'get', 'put', 'delete', etc. Do I build a tx, 
 attach 
   the callback to 'finish', then start it? Or just do: 
   
   $method = $self-req-method; 
   $self-ua-$method() 
   
   ? 
   
   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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: Troubleshooting Hypnotoad Workers

2015-04-07 Thread Jan Henning Thorsen
About SO_REUSEPORT:

https://metacpan.org/pod/Mojo::Server::Daemon#reuse
http://mojolicio.us/perldoc/Mojolicious/Guides/Cookbook#Zero-downtime-software-upgrades

On Monday, April 6, 2015 at 8:12:31 PM UTC+2, Nathan Waddell wrote:

 Yeah, I concur that the standard hot swap model probably isn't compatible 
 with a foreground process. Thanks for the input. I know I'm not deploying 
 in the 'typical' configuration, and unfortunately that's not really up to 
 me. However, I'd like to use this opportunity to try to give back somehow - 
 even if that's just putting my questions and experiences here for others 
 who might wind up in the same situation.

 I could see the possibility of writing an adapter for the service manager 
 that would handle registering the new server's pid with the service manager 
 and perhaps using the SO_REUSEPORT socket option to remain bound to the 
 same port. I could be mistaken, but I don't think that being run as a 
 foreground process == no hotswapping. I think it moves more into the idea 
 of managed hotswapping.



-- 
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: Troubleshooting Hypnotoad Workers

2015-04-06 Thread Jan Henning Thorsen
No, sending USR2 (not reloading) to a foreground process does not make any 
sense.

http://mojolicio.us/perldoc/Mojo/Server/Hypnotoad#USR2

On Monday, April 6, 2015 at 5:58:10 PM UTC+2, Nathan Waddell wrote:

 I was hoping to be able to take advantage of hot swapping, but the service 
 manager does not appear to be able to support this. I may indeed have to 
 scale back and go with prefork.

 Another configuration I am considering is running Ngix under the service 
 manager, and having Nginx start hypnotoad. Though I don't know if this 
 would comply with policy, so I will have to determine that 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] Re: Why does Mojo::Server::Daemon debugging print to STDERR?

2015-04-06 Thread Jan Henning Thorsen
That is simply not true. STDERR is not just for errors, despite the name. 
It is also for diagnostic messages, and pretty much anything that should 
not be considered the regular ouput from the application.

I will never vote in favor of allowing any such DEBUG messages (enabled by 
an environment variable) to be sent to a log file. You could however do it 
manually by redirecting STDERR (2) to a log file.

When that is said: This should never ever be done in production. Doing so 
adds an overhead that slows down your application.

The STDERR constants used through Mojolicous (and other CPAN modules) are 
simply for developers to get that extra bit of information about what is 
going on under the hood when nothing else makes sense.

I also have no idea why you want this. You ask for something, without 
explaining what it solves.

On Monday, April 6, 2015 at 4:54:21 PM UTC+2, Nathan Waddell wrote:

 Would there be value seen in a patch that allowed a log path to be used as 
 the value of MOJO_DAEMON_DEBUG?

 MOJO_DAEMON_DEBUG='/var/log/mojo.debug'

 On Monday, April 6, 2015 at 9:49:37 AM UTC-5, Nathan Waddell wrote:

 Looking at the source, I do indeed see that it uses warn.

 I am deploying hypnotoad as a foreground process being run and monitored 
 under a service manager. This service manager is designed along UNIX 
 conventions, one of which is that STDERR should be reserved for true 
 errors. 

 I think I could create a warn handler, but I imagine there would still be 
 difficulty separating true warns from simple debugging. Is there a 
 technique I could employ to work around this? 



-- 
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: Troubleshooting Hypnotoad Workers

2015-04-06 Thread Jan Henning Thorsen
Why do you use hypnotoad if running in the foreground? I don't see any 
benefit over using prefork:

  $ perl /path/to/app.pl prefork

On Monday, April 6, 2015 at 5:11:26 PM UTC+2, Nathan Waddell wrote:

 Thanks for the advice and input.

 I am running Hypnotoad underneath a UNIX service management application, 
 and after quite a bit of debugging, I am not able to replicate the problem 
 when I run Hypnotoad on its own. So perhaps this is more of a fault with 
 the service manager. Hypnotoad is running in foreground mode, launched by 
 the service manager. I'm sure this is not a typical configuration, but I 
 have to work with what I have. Hotswappability has already proven an issue 
 with the Service Manager, as during hot swap it wants to keep track of the 
 original hypnotoad server and is unaware of the new server's pid.

 I am considering writing a simple wrapper script that will launch 
 hypnotoad - something similar to Clustericious::Command::hypnotoad.

 Are there any different deployment strategies that anyone can recommend 
 for running hypnotoad / Mojo::Server::Prefork as a foreground process?

 On Saturday, April 4, 2015 at 4:17:46 AM UTC-5, sri wrote:

 How can I troubleshoot this further to determine:

1. Why does Hypnotoad think it still needs to kill non-existent 
processes?
2. Why isn't it starting new ones?


 Never seen this before, but i'll gladly track it down if you can provide 
 an example application that would allow me to replicate the problem. 
 Otherwise i'm afraid you'll have to track this down yourself, somewhere in 
 Mojo::Server::Prefork.

 https://github.com/kraih/mojo/blob/master/lib/Mojo/Server/Prefork.pm

 --
 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] Re: Troubleshooting Hypnotoad Workers

2015-04-04 Thread Jan Henning Thorsen
Sounds like you have very bad code running... Do you have a reverse proxy 
infront of hypnotoad? If you have nginx, I would probably count how many 
499, 500, 502 and 504 you got in the access log, compared to 200. I suspect 
the number is very high.

About no 
heartbeat: https://metacpan.org/pod/Mojo::Server::Prefork#heartbeat_interval

So, if your worker are doing some blocking work for more than 20 seconds 
(default), the manager (parent hypnotoad process) will kill the child 
process. And by restarted it means killing a child and starting a new one 
to do the same task.

On Friday, April 3, 2015 at 5:56:02 PM UTC+2, Nathan Waddell wrote:

 I've got an app that is served up by Hypnotoad, with no reverse proxy.It 
 has 15 workers, with 2 clients allowed apiece. The app is launched via 
 hypnotoad in foreground mode, as it is being run underneath a superdaemon 
 service manager.

 I am seeing the following in the log/production.log:

 [Wed Apr  1 16:28:12 2015] [error] Worker 119914 has no heartbeat, restarting.
 [Wed Apr  1 16:28:21 2015] [error] Worker 119910 has no heartbeat, restarting.
 [Wed Apr  1 16:28:21 2015] [error] Worker 119913 has no heartbeat, restarting.
 [Wed Apr  1 16:28:22 2015] [error] Worker 119917 has no heartbeat, restarting.
 [Wed Apr  1 16:28:22 2015] [error] Worker 119909 has no heartbeat, restarting.
 [Wed Apr  1 16:28:27 2015] [error] Worker 119907 has no heartbeat, restarting.
 [Wed Apr  1 16:28:34 2015] [error] Worker 119905 has no heartbeat, restarting.
 [Wed Apr  1 16:28:42 2015] [error] Worker 119904 has no heartbeat, restarting.
 [Wed Apr  1 16:30:12 2015] [error] Worker 119912 has no heartbeat, restarting.
 [Wed Apr  1 16:31:23 2015] [error] Worker 119918 has no heartbeat, restarting.
 [Wed Apr  1 16:32:18 2015] [error] Worker 119911 has no heartbeat, restarting.
 [Wed Apr  1 16:32:22 2015] [error] Worker 119916 has no heartbeat, restarting.

 The workers are killed, however, the workers are never restarted.

 When I run an strace, the manager process appears to be valiantly trying 
 to kill the (now expired) workers:

 Process 119878 attached - interrupt to quit
 restart_syscall(... resuming interrupted call ...) = 0
 kill(119906, SIGKILL)   = 0
 kill(119917, SIGKILL)   = 0
 kill(119905, SIGKILL)   = 0
 kill(119910, SIGKILL)   = 0
 kill(119904, SIGKILL)   = 0
 kill(119914, SIGKILL)   = 0
 kill(119916, SIGKILL)   = 0
 kill(119908, SIGKILL)   = 0
 kill(119913, SIGKILL)   = 0
 kill(119915, SIGKILL)   = 0
 kill(119918, SIGKILL)   = 0
 kill(119912, SIGKILL)   = 0
 kill(119909, SIGKILL)   = 0
 kill(119911, SIGKILL)   = 0
 kill(119907, SIGKILL)   = 0
 stat(/xxx/xxx/xxx/hypnotoad.pid, {st_mode=S_IFREG|0644, st_size=6, ...}) = 0
 poll([{fd=4, events=POLLIN|POLLPRI}], 1, 1000) = 0 (Timeout)
 kill(119906, SIGKILL)   = 0
 kill(119917, SIGKILL)   = 0
 kill(119905, SIGKILL)   = 0
 kill(119910, SIGKILL)   = 0
 kill(119904, SIGKILL)   = 0
 kill(119914, SIGKILL)   = 0
 kill(119916, SIGKILL)   = 0
 kill(119908, SIGKILL)   = 0
 kill(119913, SIGKILL)   = 0
 kill(119915, SIGKILL)   = 0
 kill(119918, SIGKILL)   = 0
 kill(119912, SIGKILL)   = 0
 kill(119909, SIGKILL)   = 0
 kill(119911, SIGKILL)   = 0
 kill(119907, SIGKILL)   = 0
 stat(/xxx/xxx/xxx/hypnotoad.pid, {st_mode=S_IFREG|0644, st_size=6, ...}) = 0
 poll([{fd=4, events=POLLIN|POLLPRI}], 1, 1000^C unfinished ...
 Process 119878 detached

 How can I troubleshoot this further to determine:

1. Why does Hypnotoad think it still needs to kill non-existent 
processes?
2. Why isn't it starting new ones?



-- 
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: Strange route behavior

2015-02-15 Thread Jan Henning Thorsen
The reason is that you have default values set for :year and :month, so 
they get filled in, when not specified.


On Sunday, February 15, 2015 at 10:43:27 AM UTC+1, Stanislav Blinov wrote:

 Hi,
 I have a route: 
 $r-get('/news/:year/:month' = [month = qr/\d{2}/, year = 
 qr/\d{4}/])-to(controller = 'news', action = 'view', year = 2015, month 
 = 01, page = 1, id = $news_id);

 My intention is that it only should work for these type of urls:
 /news/
 news/2015/
 news/2015/01

 However, it also works when I call /news.html

 What is wrong with it?
 I have also tried adding .html to another routes and it seems that they 
 open the same page as a route without .html

 Mojolicious 5.79.



-- 
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: Interactive debugging in Mojolicious tests

2015-01-30 Thread Jan Henning Thorsen
Most tests are plain perl scripts, so you should be able to just do

perl -d t/mytest.t


On Friday, January 23, 2015 at 12:31:31 AM UTC+1, Daniel Mantovani wrote:


 I wonder if there is a recommended way to run Mojolicious tests  under 
 perl debugger.

 Actually I saw that if you write a Makefile.PL with Exutils::MakeMaker and 
 then

 perl Makefile.PL
 make

 you will be able to run Mojo tests under perl debugger like this:

 make testdb TEST_FILE=t/mytest.t


 (explained at 
 https://metacpan.org/pod/release/BINGOS/ExtUtils-MakeMaker-7.04/lib/ExtUtils/MakeMaker.pm#make-testdb
 )

 That works, but I guess it should be a better way, probably without the 
 need to write a Makefile.

 Any comments / thoughts will be appreciated.
 BR,
 Daniel




-- 
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-18 Thread Jan Henning Thorsen
Yes. That is what I tried to write :-)

On Thursday, December 18, 2014 12:41:39 AM UTC+1, Charlie Brady wrote:


 On Wed, 17 Dec 2014, Jan Henning Thorsen wrote: 

  Pavel, you can do this: 
  
  my $b = __PACKAGE__-can($a); 
  $b-(stuff) if $code; 

 I guess you mean: 

 $b-(stuff) if $b; 


-- 
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: Handle database errors with Mojo::Pg

2014-12-17 Thread Jan Henning Thorsen
I think sri meant Mojo::Pg does not actually emit an error event.

Anyhow...

You should handle the error somehow. If you don't want to, then the best 
strategy is simply to die $err if $err;. That way, the error will 
propagate correctly and result in a 500 page.

By handling, I mean checking if you can continue in your app, doing 
something else.


On Sunday, December 14, 2014 2:36:21 PM UTC+1, sri wrote:

 I was hoping that I could handle this error through the error event (as in 
 Mojo::UserAgent when the error is not bound to a tx), but it seems not 
 working:


 Mojo::UserAgent does not actually emit an error event.

 --
 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.


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

2014-12-17 Thread Jan Henning Thorsen
Pavel, you can do this:

my $b = __PACKAGE__-can($a);
$b-(stuff) if $code;

You can replace __PACKAGE__ with whatever package name you want.

The special symbol __PACKAGE__ contains the current package,
can() returns a ref to a function/method if $a has the correct method name 
which can be found in the class or any of the inherited classes.
 

On Friday, December 12, 2014 8:12:36 PM UTC+1, Pavel Serikov wrote:

 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] Swagger2: The World's Most Popular Framework for APIs

2014-12-09 Thread Jan Henning Thorsen
Hi,

I'm working on a new module that takes advantage of the Swagger2 API 
documentation format.

https://metacpan.org/release/Swagger2
https://metacpan.org/release/JHTHORSEN/Swagger2-0.03 (in case 0.03 isn't 
visible from the line above)

Features:
* Automatic route generation
* Input/output validation in your Mojoliicous applicaiton
* Swagger documentation to Perl documentation (POD)
* JSON Schema validation

Plans:
* Add Swagger::Client which wraps around Mojo::UserAgent and enables 
input/output validation

Any feedback/ideas are very 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: automatic versioning

2014-11-13 Thread Jan Henning Thorsen
Hi,

I would suggest trying 
out https://metacpan.org/pod/Mojolicious::Plugin::AssetPack

Any feedback is more than welcome.


On Tuesday, November 11, 2014 11:18:40 AM UTC+1, Mark Hardwick wrote:

 Hey Guys
 I'm new to mojolicious and also trying to port a fairly large mod_perl 
 application over to using it, so you're like to see a few newbie questions 
 from me.

 First thing, the current application uses File::Hashcache to provide 
 automatic versioning of css and js files.  It works really well.  

 I can't tell if automatic versioning is something that mojolicious does 
 for me or if I need to integrate Hashcache (or something similar) into 
 Mojolicious.  

 If I do need to integrate Hashcache, could someone point in the right 
 direction?  
 I've read the documentation on Rendering (which I assume would be the 
 place to start), but I can't see how I'd do it (assuming it can be done).

 Cheers



-- 
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: Using hypnotoad with a local-lib-contained Mojolicious install

2014-10-18 Thread Jan Henning Thorsen
perl -I is not inherited through exec(). You're better off using:

  PERL5LIB=$PWD/perl5/lib/perl5 $PWD/perl5/bin/hypnotoad

This way, PERL5LIB is set for the current process and all the sub processes 
started with exec(). Note the $PWD part, which will make sure it's set to 
an absolute path.

On Saturday, October 18, 2014 6:01:15 AM UTC+2, perlpong wrote:

 This is not a bug-report or a request for help, I am just sharing my 
 experience.

 I install Mojolicious inside an app-local directory using cpanm's -L 
 switch:

 .
 |─- perl5/
 |   |-- bin/
 |   |   |-- hypnotoad
 |   |   |-- mojo
 |   |   |-- morbo
 |   |-- lib/
 |   |-- perl5/
 |   |-- Mojo/
 |   |-- Mojo.pm
 |   |-- Mojolicious/
 |   |-- Mojolicious.pm
 |-- script/
|-- app.pl

 I run hypnotoad with Perl's -I flag to append my local-lib directory to 
 the beginning of @INC:

 perl -Iperl5/lib/perl5 perl5/bin/hypnotoad ./script/myapp.pl

 My app logs an error related to Mojolicious:

 Can't locate object method every_param via package Mojo::Parameters

 After investigating I realise that my global install of Mojolicious is 
 being loaded instead of my local one.

 If I dump @INC at the beginning of the hypnotoad script, it produces this:

 (
   /home/ac/apps/MyApp/perl5/bin/../lib,
   perl5/lib/perl5/i686-linux,
   perl5/lib/perl5,
   
 /home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/i686-linux,
   /home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1,
   /home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/5.16.1/i686-linux,
   /home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/5.16.1,
   .,
 )
 (
   /home/ac/apps/MyApp/perl5/bin/../lib,
   
 /home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/i686-linux,
   /home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1,
   /home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/5.16.1/i686-linux,
   /home/ac/perl5/perlbrew/perls/perl-5.16.1/lib/5.16.1,
   .,
 )

 It appears that the process restarts itself, the second time without my 
 modified @INC.

 Looking inside Mojo::Server::Hypnotoad, I notice this:

 $ENV{HYPNOTOAD_EXE} ||= $0;
 ...
 # Clean start (to make sure everything works)
 die Can't exec: $! if !$ENV{HYPNOTOAD_REV}++  !exec 
 $ENV{HYPNOTOAD_EXE};

 So my workaround is to manually set the HYPNOTOAD_EXE environment variable:

 export HYPNOTOAD_EXE=perl -Iperl5/lib/perl5 perl5/bin/hypnotoad
 perl -Iperl5/lib/perl5 perl5/bin/hypnotoad ./script/myapp.pl


-- 
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] Mad::Mapper - Async ORM (kind of)

2014-10-14 Thread Jan Henning Thorsen
Hi,

I've just started the other day a new project, which is kind of an ORM, but 
where instead of having the database in center, you simply use it as a 
place to store your object. So.. How is that different? From what I'm used 
to, you usually make export your database schema into Perl space, and 
work with the tables and columns, using classes and accessors. What I'm 
proposing instead is that you simply add some extra methods to your 
existing objects to enable them to be persistent in some backend storage.

For now, I'm mostly focusing on using Mojo::Pg and Mojo::mysql as backends, 
but I don't see any harm in using any (async) backend.

The project is on github, and it's working except of the has_many in the 
SYNOPSIS.

https://github.com/jhthorsen/mad-mapper

I'm not sure where to continue on from here or if I even should. Any 
feedback is more than welcome.

-- 
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: Mojo::mysql

2014-10-12 Thread Jan Henning Thorsen
Quick: Yeah, it was easy to make, since you had done all the hard work 
Sebastian :-)

Step 1: Search and replace (pg|postgres) with mysql
Step 
2: 
https://github.com/jhthorsen/mojo-mysql/commit/f67f48c4b97176275e50b52b66355338f0c70f9d
Step 
3: 
https://github.com/jhthorsen/mojo-mysql/commit/9a5fbc619a20ad5db25cdbced7c4f852a6be21de

About step #3. I'm not sure if what I'm doing there is a hack or not. Any 
MySQL people out there that can comment on this? The fix to make UTF8 work 
is to both set the mysql_enable_utf8 and make sure the table has COLLATE 
= utf8_bin. Is the way to store/read UTF8 from MySQL?

I suggest others to follow the same steps, if it's possible for other DBD 
drivers. It's nice to have the same API - especially when the API makes 
sense. I was looking at SQLite, but couldn't find any async support. I'm a 
bit surprised, since it's a file on disk... (Let's open a new thread if 
someone wants to make discuss this further)


On Saturday, October 11, 2014 10:49:42 PM UTC+2, sri wrote:

 Today I release Mojo::mysql, a fork of Sebastian's Mojo::Pg which allow 
 you to use the same API, but against the MySQL database.

   https://metacpan.org/release/JHTHORSEN/Mojo-mysql-0.01


 Yay, that was quick!
  

 I'm also unsure if I will add migration support to Mojo::mysql, even if 
 Mojo::Pg gets migrations support. I will however (most probably) accept 
 pull requests for this feature.


 Yea, i think you're better off not implementing migrations, MySQL lacks 
 support for transactional ddl, which is what makes migrations for 
 PostgreSQL so awesome. Yesterday i was still a bit unsure if migrations are 
 going to stay in Mojo::Pg, but the ability to have your database schema 
 sync automatically and safely on startup is just too good. So they will say.

 --
 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] Mojo::mysql

2014-10-11 Thread Jan Henning Thorsen
Hi,

Today I release Mojo::mysql, a fork of Sebastian's Mojo::Pg which allow you 
to use the same API, but against the MySQL database.

  https://metacpan.org/release/JHTHORSEN/Mojo-mysql-0.01

This module is EXPERIMENTAL, due to the nature of Mojo::Pg. I don't want to 
freeze the API until I know it can mirror the API of Mojo::Pg.

There is one thing lacking in Mojo::mysql, and that is the events related 
to notifications. This is simply because this is not a feature in MySQL. 
I'm also unsure if I will add migration support to Mojo::mysql, even if 
Mojo::Pg gets migrations support. I will however (most probably) accept 
pull requests for this feature.

See also

* https://groups.google.com/d/msg/mojolicious/4d5MckGYmEg/339pG01IV30J
* https://metacpan.org/release/Mojo-Pg


Also, there's a module called Mojo::MySQL on CPAN. That module and it's 
namespace will be deleted in a couple of days.

-- 
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: Need help (feedback) with Mojo::Redis2 - A new pure-perl non-blocking I/O Redis driver

2014-10-04 Thread Jan Henning Thorsen
This makes a new connection on each request:

helper redis = sub { shift-stash-{redis} ||= Mojo::Redis2-new(url = 
$redis_server)};


On Saturday, October 4, 2014 2:46:56 AM UTC+2, Daniel Mantovani wrote:

 I was trying to handle several subscribe channels with only one redis 
 client using Mojo::Redis2, but it seems that I'm doing something wrong, I 
 end up using as many clients as open subscribed channels I have.

 Maybe somebody can take a look at this test code and let me know :

 https://github.com/dmanto/test-redis-connections.git

 Thanks in advance,

 El martes, 5 de agosto de 2014 11:04:45 UTC-3, Jan Henning Thorsen 
 escribió:

 I pushed an experimental release to CPAN now:

 https://metacpan.org/pod/Mojo::Redis2

 -Any- feedback is more than welcome.

 On Sunday, June 29, 2014 10:21:28 PM UTC+2, Daniel Mantovani wrote:

 Perfect then, thanks Jan

 El domingo, 29 de junio de 2014 03:50:09 UTC-3, Jan Henning Thorsen 
 escribió:

 The on(message = $channel = ...) API is not going to be part of 
 Mojo::Redis2. It will just be on(message = sub { my ($self, $message, 
 $channel) = @_ }); The reason for that is to have a consistent API. (on() 
 is already defined in Mojo::EventEmitter)

 And yes, it will only have one connection to the Redis server pr. 
 $redis object, even though you do $redis-subscribe(channel:$_) for 
 1..1;

 I'm planning to have one connection for the pubsub 
 http://redis.io/commands#pubsub commands, a new connection when you 
 call blpop, brpop, brpoplpush http://redis.io/commands#list, and one 
 connection for everything else. The reason for creating a new connection 
 on 
 each blpop(), brpop(), brpoplpush http://redis.io/commands#list() is 
 that they are blocking on the server side.


 On Saturday, June 28, 2014 2:12:01 AM UTC+2, Daniel Mantovani wrote:

 Yes it absolutly matters, I need a different channel per connected 
 websocket

 So if I understood correctly inside my websocket route I could write 
 something like:

 my $applianceid = ... (some unique identifier for each appliance, I 
 get it from a custom header)
 my $redis = Mojo::Redis2-new;
 $redis-on(message = myapp:$applianceid, sub {
   my ($rself, $msg) = @_;
   .
   do something with the received redis msg
   .
   $tx-send($something); # use my transaction object to send some data 
 to my connected appliance

   etc

 });
 ...

 and still use just one redis client despite I may have thousands of 
 websocket clients connected and subscribed to different channels 
 (myapp:$applianceid)?

  In this case I think the solution would be perfect, I don´t care 
 using one extra redis client for publishing, that I guess I will be able 
 to 
 share among all websockets.

  So at the end of the day I will be using just two redis clients per 
 toad when running on hypnotoad... is that right or I missunderstood?


 El viernes, 27 de junio de 2014 10:11:52 UTC-3, Jan Henning Thorsen 
 escribió:

 I had some typos:
 I meant subscribing to foo and then bar. (not sure if that 
 matters for the example though)
 Also the $old comments should be now there is two connections to the 
 Redis database.

 On Friday, June 27, 2014 3:09:35 PM UTC+2, Jan Henning Thorsen wrote:

 Mojo::Redis2 can (or at least it will be able to) (p)subscribe 
 multiple times, using just one connection. I will try to illustrate the 
 difference to be sure I understand you: 

   my $old = Mojo::Redis-new;
   my $s1 = $old-subscribe(foo);
   my $s2 = $old-subscribe(foo);
   # now you two connections to the Redis database

   my $new = Mojo::Redis2-new;
   $new-subscribe(foo);
   $new-subscribe(foo);
   # still just one connection to the Redis database, since 
 Mojo::Redis2 is re-using the same subscribe connection

 Unfortunatly, issuing (P)SUBSCRIBE will only allow subscribe like 
 commands http://redis.io/commands/subscribe, which renders any 
 Redis module unable to do PUBLISH and SUBSCRIBE over the same database 
 connection. 

 On Friday, June 27, 2014 3:00:20 PM UTC+2, Daniel Mantovani wrote:

   Hi Jan, I´ve using Mojo::Redis and find it very convenient as the 
 glue that allows to comunicate non-blocking among different processes 
 (toads) when running hypnotoad (using subscribe and publish, just as 
 the 
 Websocket example in the module's synopsis).

  Something I would suggest for you to take a look is related to the 
 scalling of simultaneos redis clients needed for a realtime app. I 
 understand that you would need a dedicated subscribe client plus a 
 publish per connected websocket, if you follow the mencioned example.

  That could be a problem depending on the nature of your app. In my 
 case I was working on an app that will have thousand of appliances 
 with 
 very low traffic but allways on, so I ended up using Mojo ::Redis with 
 something like a psubscribe app:* client per toad, and just one 
 publishing client (probably blocking) also per toad (Anyway  I'm not 
 sure 
 how this solution will scale in the field, we will see

[Mojolicious] Re: Connections pool to Redis for Mojo

2014-10-02 Thread Jan Henning Thorsen
Hi,

I'm not sure how to do that. You could create a shared connection in each 
fork and then re-use that, but I have no idea how that would actually work.

  helper redis = sub {
my $c = shift;
$c-app-defaults-{redis} ||= Mojo::Redis2-new;
  };

I've never tried that myself (since I don't like sharing connections 
between requests), but it should work if you're only doing simple things 
like get/set/...

Mojo::Redis2 doesn't have a pool, but it has a single connection pr 
operation type: blocking/non-blocking/pubsub/...

Patches are welcome though :) (I've written Mojo::Redis2 and contributed to 
Mojo::Redis) 


On Wednesday, October 1, 2014 9:09:51 PM UTC+2, Alberto Mijares wrote:

 Hi list, 

 I'd like to keep a fixed number of open connections to Redis and each 
 time the app is reached by a request, the query is send using one of 
 these previously opened connections. 

 Can you give me some ideas on how to achieve this in the Mojo way? Any 
 reference? 

 Thanks in advance, 

 Alberto Mijares 


-- 
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: What databases are you using with Mojolicious? (Poll)

2014-09-29 Thread Jan Henning Thorsen
Hi,

I'm using Redis, MySQL, SQLite for testing and occasionally MongoDB. In 
future I think I will be using PostgreSQL.

I'm using Mojo::Redis2 for Redis. (I'm the author)
I'm using DBI and DBIx::Class with SQLite, MySQL and PostgreSQL.
I'm using Mango+Mandel for MongoDB. (I'm the author of Mandel)

Side note: I wonder what to do with Mandel. If anyone is up for it, I will 
gladly give commit bit and access to PAUSE (send me an direct email or make 
a github issue)

I've also (barely) started a non-blocking API for SQL: 
https://github.com/jhthorsen/mojo-sql Current state: Not working. Plain 
awful code. I'm also still trying to figure out what kind of API that makes 
sense: Raw SQL vs datastructures. (send me an direct email if you're 
interested)


Regards,
Jan Henning Thorsen (batman)

On Sunday, September 28, 2014 6:22:48 PM UTC+2, Alberto Mijares wrote:

 Hi, 

 I'm just starting a new project with Mojolicious::Lite and Redis. 

 Regards, 


 Alberto Mijares 



 On Sun, Sep 28, 2014 at 11:44 AM, Антон Щанкин 
 anton.shchan...@yandex.ru wrote: 
  Hello! 
  I am using PostgreSQL with DBIx::Class now, old projects living on MySQL 
 and 
  Rose::DB::Object and older projects is on BerkleyDB =) 
  For schema migrations i have own tool ( like DBIx::Migration ) and 
  DBIx::Class::Schema::Loader ( its also very helpfully if you need take 
 live 
  project with big schema for rewriting on perl/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 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] Cutesy dates (going full stack or not)

2014-08-28 Thread Jan Henning Thorsen
I also don't see this as a core feature. I would also not render relative 
timestamps on server side, but rather let this to be done on client side to 
improve caching. Something like this:

  span data-timestamp=%= time % class=timestamp%= 
pretty_absolute_time %/span

Doing it on the client side also has advantages by allowing the less than 
a minute ago string to be changed as time goes along in the browser.

On Thursday, August 28, 2014 7:37:21 AM UTC+2, Justin Hawkins wrote:


 On 28 Aug 2014, at 1:25 pm, sri kra...@googlemail.com wrote: 

  A few words about the motivation. Like many Perl hackers, since the 
 closure of Google Groups i'm a regular visitor of the Planet Perl Iron Man 
 site (http://ironman.enlightenedperl.org/), which is a very good example 
 for something quickly hacked together and never cleaned up. You don't even 
 have to look at the code, which still sports the stub documentation 
 generated by Catalyst. One of the first thing that jumped into my eye were 
 those horrible timestamps, even for a quick hack you should never have to 
 choose those. Mojolicious needs to be better than that, making 
 aesthetically pleasing applications has to be easy by default. 

 I share this pet peeve. I’ve been using Time::Duration since … forever. 

 Mojo::Date has a nicer interface, but I still don’t know how I feel about 
 it being in core. 

 I can see the arguments for - date and time handling comes up in almost 
 any non-trivial web app, and you might as well make it look good and make 
 sense. 

 Overall I think I’m in favour. Not sure about the ‘cutesy dates’ name :-) 

 - Justin

-- 
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] Cutesy dates (going full stack or not)

2014-08-28 Thread Jan Henning Thorsen
Stefan: That is indeed a Mojolicious template. What I meant is that I want 
to provide a pretty absolute time (not like the ironman webpage) and then I 
replace that on the client side with whatever data-timestamp holds. 
time() = something computers (javascript) can understand and 
pretty_absolute_time() is something humans can read.

Another thing is that pretty_absolute_time() makes also more sense if you 
plan to print the webpage. Therefor I wouldn't replace the span tag, but 
rather hide it by default on media screen and show it on media print.


On Thursday, August 28, 2014 2:49:44 PM UTC+2, Stefan Adams wrote:


 On Thu, Aug 28, 2014 at 7:32 AM, Jan Henning Thorsen 
 jan.henn...@thorsen.pm wrote:

 Something like this:

   span data-timestamp=%= time % class=timestamp%= 
 pretty_absolute_time %/span


 Are you saying that is on the client side?  But that's a Mojolicious 
 template and therefore rendered on the server site, yes?  Isn't 
 pretty_absolute_time a Perl function in this case?



-- 
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] Cutesy dates (going full stack or not)

2014-08-28 Thread Jan Henning Thorsen
The big difference is that I got pretty ABSOLUTE time as a fallback, 
while https://github.com/kraih/mojo/compare/time_in_words is used to create 
pretty RELATIVE time.

On Thursday, August 28, 2014 4:46:03 PM UTC+2, Stefan Adams wrote:


 On Thu, Aug 28, 2014 at 7:58 AM, Jan Henning Thorsen 
 jan.henn...@thorsen.pm wrote:

 Stefan: That is indeed a Mojolicious template. What I meant is that I 
 want to provide a pretty absolute time (not like the ironman webpage) and 
 then I replace that on the client side with whatever data-timestamp 
 holds. time() = something computers (javascript) can understand and 
 pretty_absolute_time() is something humans can read.

 Another thing is that pretty_absolute_time() makes also more sense if you 
 plan to print the webpage. Therefor I wouldn't replace the span tag, but 
 rather hide it by default on media screen and show it on media print.


 Thanks for the response, Jan.  I think this makes sense, however, as I 
 understand it you're still calling a Perl function to output pretty time / 
 cutesy dates -- the very function that Sri was proposing and that you were 
 suggesting isn't useful because you like to render it on the client 
 (javascript).  But it sounds like you are still rendering cutesy dates on 
 the server.  I'm not suggesting that this is sufficient cause to introduce 
 cutesy dates into Mojo core by any means, just trying to keep up with you 
 in the conversation and understand your response and rationale.  Sorry for 
 my inability to understand better.  :D
  

-- 
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] Cutesy dates (going full stack or not)

2014-08-28 Thread Jan Henning Thorsen
Yes. 5:00 pm versus 5 minutes ago is a huge difference.

Yes. I think you missed the point. The point was to provide nice 
timestamps in templates (or where ever)

On Thursday, August 28, 2014 5:05:05 PM UTC+2, Stefan Adams wrote:


 On Aug 28, 2014 9:50 AM, Jan Henning Thorsen jan.henn...@thorsen.pm 
 wrote:
 
  The big difference is that I got pretty ABSOLUTE time as a fallback, 
 while https://github.com/kraih/mojo/compare/time_in_words is used to 
 create pretty RELATIVE time.

 I understand the focus of your distinction now. 5:00 pm versus 5 
 minutes ago. Yes?

 Perhaps I missed it sri, I was curious what your motivation was for 
 supplying relative time such as 5 minutes ago.

 When I initially saw your commit I thought that you were interested in 
 showing some core logging in the debugger that something happened 5 minutes 
 ago or such.

 Anyway... Sorry to beat a dead horse. Just curious.

  On Thursday, August 28, 2014 4:46:03 PM UTC+2, Stefan Adams wrote:
 
 
  On Thu, Aug 28, 2014 at 7:58 AM, Jan Henning Thorsen 
 jan.henn...@thorsen.pm wrote:
 
  Stefan: That is indeed a Mojolicious template. What I meant is that I 
 want to provide a pretty absolute time (not like the ironman webpage) and 
 then I replace that on the client side with whatever data-timestamp 
 holds. time() = something computers (javascript) can understand and 
 pretty_absolute_time() is something humans can read.
 
  Another thing is that pretty_absolute_time() makes also more sense if 
 you plan to print the webpage. Therefor I wouldn't replace the span tag, 
 but rather hide it by default on media screen and show it on media 
 print.
 
 
  Thanks for the response, Jan.  I think this makes sense, however, as I 
 understand it you're still calling a Perl function to output pretty time / 
 cutesy dates -- the very function that Sri was proposing and that you were 
 suggesting isn't useful because you like to render it on the client 
 (javascript).  But it sounds like you are still rendering cutesy dates on 
 the server.  I'm not suggesting that this is sufficient cause to introduce 
 cutesy dates into Mojo core by any means, just trying to keep up with you 
 in the conversation and understand your response and rationale.  Sorry for 
 my inability to understand better.  :D
 
  -- 
  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.
  

-- 
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: Wishlist thread (second edition)

2014-08-25 Thread Jan Henning Thorsen
Viktor: Mojolicious::Plugin::Bootstrap3 include styling for 
field-with-error:
https://metacpan.org/pod/Mojolicious::Plugin::Bootstrap3#Non-standard-files


On Mon, Aug 25, 2014 at 7:34 PM, sri kra...@googlemail.com wrote:

 Making 'field-with-error' something you can set, e.g.

 app-validator-error_class('has-error')


 There's already a helper that can be redefined.


 http://mojolicio.us/perldoc/Mojolicious/Plugin/TagHelpers#tag_with_error

 --
 sebastian

 --
 You received this message because you are subscribed to a topic in the
 Google Groups Mojolicious group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/mojolicious/mIRRwNwDLSE/unsubscribe.
 To unsubscribe from this group and all its topics, 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.


-- 
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: Randomness in a template

2014-08-21 Thread Jan Henning Thorsen
Stefan: It's probably because the random seed has been initialized in the 
parent process. See http://perldoc.perl.org/5.10.1/functions/srand.html for 
more details.

You could try to call srand in each chile process:

  sub startup {
my $app = shift;
# this code is run in parent process

# this next_tick() code is run once in each forked child
Mojo::IOLoop-next_tick(sub { srand });
  } 

On Thursday, August 21, 2014 8:00:05 AM UTC+2, Stefan Adams wrote:

 I have a template:

 % use List::Util 'shuffle';
 % my @roster = shuffle @$roster;

 And when using hypnotoad I don't get a new randomized roster list on every 
 page refresh.  It seems that I have about 4 possible randomized lists that 
 my browser may display, presumale because I have 4 hypnotoad processes 
 running and handling requests.

 I assume this is expected.  What can I do to get the behavior that I'm 
 looking for which is a randomized list on every page refresh?

 Naturally, with morbo, it's a new randomized list on every page refresh.
  

-- 
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: multiple authentication methods?

2014-08-21 Thread Jan Henning Thorsen
I think it's a very bad idea to only allow one login from one browser. I 
often log in to facebook, twitter, google, demo.convos.by, ..., from 
multiple browsers at the same time.

I would probably do something like this:

  $c-session(uid = $user-username, sid = $session_row-id);

That way you can allow multiple users being logged in at the same time from 
multiple devices. If something is shared across browsers, you can use the 
uid and if something is unique per browser, you can use the session row 
to store data.

On Wednesday, August 20, 2014 8:01:09 PM UTC+2, Richard Sugg wrote:

 What's the best way to handle multiple authentication methods? I normally 
 have users login and create a session in the database. A user can only 
 login once at a time. If they open another browser and login, their first 
 session is invalidated. However, I also want to use some of the same urls 
 for automated processes which might run in parallel. If a two processes try 
 to authenticate and call a url, only the second process will have a valid 
 session. So for automation, it makes better sense to use Basic auth and 
 leave sessions to actual users. 

 So what's the best way to handle this? Would I have to write a bridge that 
 checks one method and then the other? Or is there a better way?


-- 
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: Randomness in a template

2014-08-21 Thread Jan Henning Thorsen
You're welcome :)

On Thursday, August 21, 2014 2:32:25 PM UTC+2, Stefan Adams wrote:


 On Thu, Aug 21, 2014 at 7:11 AM, Jan Henning Thorsen 
 jan.henn...@thorsen.pm wrote:

 sub startup {
 my $app = shift;
 # this code is run in parent process

 # this next_tick() code is run once in each forked child
 Mojo::IOLoop-next_tick(sub { srand });


 Thanks, Jan!  This exactly solved it for me!


-- 
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] Digest authentication handler for Mojo::UserAgent

2014-08-13 Thread Jan Henning Thorsen
Hi,

I've created a module for handling digest authentication for non-blocking 
Mojo::UserAgent operations:

  use Mojo::UserAgent::DigestAuth;
  my $ua = Mojo::UserAgent-new;

  $ua-get(http://username:password\@example.com;, digest_auth {
my ($ua, $tx) = @_;
# ...
  });

Could someone give me feedback on the module? Does the code make sense? 
Should I rename it?

The code is located on 
github: https://github.com/jhthorsen/mojo-useragent-digestauth

-- 
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: $self-stash() on go slow from ver 4.84 onwards

2014-07-31 Thread Jan Henning Thorsen
Maybe I'm mistaken, but I think you can make your code faster as well...

get '/' = sub {
my $self = shift;
my $sth = $self-db-prepare('SELECT id, content FROM updates');
my %data;

$sth-execute;

while (my $r = $sth-fetchrow_arrayref) {
$data{$r-[0]} = $r-[1];
}

$self-render('invalid', %data);
};

1) fetchrow_arrayref() is faster than fetchrow_hashref(). And it works, 
since you know the position of the columns because of the modified SELECT 
statement.
2) You only loop once. Which is at least twice as fast.
3) You never call stash, but pass the %data directly on to render() instead.

A completely different thing is that the code doesn't do any error 
checking. I would suggest using https://metacpan.org/pod/DBI#RaiseError

On Thursday, July 31, 2014 10:05:34 AM UTC+2, Peter Robb wrote:

 Wow !

 Very nice changes.. :-)
 And quick too.
 Thanks.

 Peter
 On 31 Jul 2014 02:00, sri kra...@googlemail.com wrote:

 Dunno, thousands of method calls is generally not a smart thing to do, 
 optimizing for it seems wrong.


 I am trying a few things that appear to improver overall performance 
 though, more proposals along those lines would be welcome.

 
 https://github.com/kraih/mojo/commit/157cea1a448bdc2b7768822bfbe944fd8530db62

 --
 sebastian 

 -- 
 You received this message because you are subscribed to a topic in the 
 Google Groups Mojolicious group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/mojolicious/KTGEl4GjKkU/unsubscribe.
 To unsubscribe from this group and all its topics, 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.



-- 
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: Testing commands

2014-07-27 Thread Jan Henning Thorsen
What I do is that I factor out most of the code from run() in the command, 
so I can test it with normal Test::More:

  use Mojo::Base -strict;
  use Test::More;
  use MyApp::Command::foo;
  my $cmd = MyApp::Command::foo-new;
  is $cmd-get_some_stuff, 42, 'do_stuff() returned 42';
  done_testing;

You could also test run() the same way ^^^.

Note: You might want set app():

  my $cmd = MyApp::Command::foo-new;
  $cmd-app(Mojo::Server-new-build_app(MyApp));

On Friday, July 25, 2014 4:00:43 PM UTC+2, jay m wrote:



 On Friday, July 25, 2014 7:34:45 AM UTC-4, sri wrote:

 The Test::Mojo doc is clear about testing the web part of a Mojo 
 application, but how are custom Mojo commands tested?


 Because there is nothing, proposals welcome.


 in real usage, commands are initiated from outside mojo (command line) and 
 the results are evaluated externally. so do we need any special features 
 for testing them beyond what Test::More provides?

 my $out = `$bdir/script/mojo usercount -m testing`;
 like $out,qr[users: 4/3],'total/active users loaded by fixtures';

 jay



-- 
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: Using different user agents in controller

2014-07-27 Thread Jan Henning Thorsen
Oh! Sorry. I missed that point.

You can't: The Mojo::UserAgent attributes are bound to the object.

On Sunday, July 27, 2014 1:06:33 PM UTC+2, Andrey Khozov wrote:

 Thanks for the answer!

 Btw, how can I use different setting of user agent (timeouts, proxy, etc) 
 for different requests using one instance of Mojo::UserAgent?


 On Sun, Jul 27, 2014 at 4:59 PM, Jan Henning Thorsen 
 jan.henn...@thorsen.pm wrote:

 The difference is that $c-ua does not go out of scope. $ua = 
 Mojo::UserAgent-new need to be kept alive manually. Example:

   # this will never complete, because $ua gets garbage collected:
   get /foo = sub {
 my $c = shift;
 my $ua = Mojo::UserAgent-new;
 $ua-get(example.com = sub { ... });
   };

   # this on the other hand works:
   get /foo = sub {
 my $c = shift;
 my $ua = Mojo::UserAgent-new;
 $self-stash(my_ua = $ua);
 $ua-get(example.com = sub { ... });
   };

 Also, You don't have to create more Mojo::UserAgent object. The same ua 
 object can do all the requests.


 On Sunday, July 27, 2014 12:42:36 PM UTC+2, Andrey Khozov wrote:

 Can you explain what is the difference between

 my $ua = $c-ua;

 and

 my $ua = Mojo::UserAgent-new(server = Mojo::UserAgent::Server-new(app 
 = $c-app));

 in controller? (except weaken reference to app)


 On Fri, Jul 25, 2014 at 7:09 PM, Andrey Khozov avkho...@googlemail.com 
 wrote:

 Yes, I see this. But in this case client should wait while user agent 
 processing requests (while delay is not finished) ?


 P.S. links with anchor broken for now.


 On Fri, Jul 25, 2014 at 7:01 PM, sri kra...@googlemail.com wrote:

 http://mojolicio.us/perldoc/Mojolicious/Guides/FAQ#What_
 does_\%22Premature_connection_close\%22_mean\%3F 
 http://mojolicio.us/perldoc/Mojolicious/Guides/FAQ#What_does_%5C%22Premature_connection_close%5C%22_mean%5C%3F

 --
 sebastian




 -- 
 Andrey Khozov 




 -- 
 Andrey Khozov 




 -- 
 Andrey Khozov 


-- 
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: What's the proper way to retrieve the client's IP address?

2014-07-23 Thread Jan Henning Thorsen
If you have set up the reverse proxy correct, you can just do 
$c-remote_address;

No idea why you want to look into the tx hash. You should always use the 
methods.

Look here: (there's also cookbooks for other servers on that page)
https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Cookbook.pod#Nginx
https://metacpan.org/pod/Mojo::Transaction#remote_address

Also remember to set the MOJO_REVERSE_PROXY=1 environmnt variable as I said 
earlier in this thread.
https://metacpan.org/pod/Mojo::Server#reverse_proxy
https://metacpan.org/pod/Mojo::Server::Hypnotoad#proxy


On Wednesday, July 23, 2014 1:17:54 PM UTC+2, Юрий Корик wrote:

 What's the right way to retrieve the client's IP address? 

 Create helper:

 $self-renderer-add_helper(ip = sub {
   my $self = shift;
   my $for  = $self-req-headers-header('X-Forwarded-For');
   return $for  $for !~ /unknown/i ? $for : undef || 
 $self-req-headers-header('X-Real-IP') || $self-tx-{remote_address};
 });




-- 
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: Found the interesting bug

2014-07-18 Thread Jan Henning Thorsen
You need to provide the script that does the request as well. I'm pretty 
sure it's a shell flush- or prompt-thing that trick you.

And the oneliner that sri posted is actually a lite app.


On Friday, July 18, 2014 2:16:12 PM UTC+2, Александр Грошев wrote:

 $ perl -Mojo -E 'get / = sub { shift-render(text = Hello) }; 
 app-start' get /
 Hello

 Yes, it's working correctly. But in script with Mojolicious::Lite i have 
 that error. 


-- 
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] What's the proper way to retrieve the client's IP address?

2014-07-14 Thread Jan Henning Thorsen
Try setting { hypntoad = { proxy = 1, listen = [...] } in the config 
file, if you are using hypnotoad, or set the MOJO_REVERSE_PROXY=1 
environment variable in other cases. Support for the environment variable 
was added in Mojolicious 5.11.

This will allow retrieving the IP address using $self-tx-remote_address

On Sunday, July 13, 2014 1:34:14 AM UTC+2, Alexander Karelas wrote:

 I think that contains a comma-separated list of IP addresses, whereas 
 the X-Real-IP header always contains just one address. 

 - Alex 


 On 07/12/2014 10:58 PM, Luc Didry wrote: 
  On 12/07/2014 21:46, Alexander Karelas wrote: 
  I know there's $self-tx-remote_address, but that retrieves the 
 address 
  of the reverse proxy (127.0.0.1). 
  
  Because even though I have set up a X-Real-IP header and a 
  X-Forwarded-For header, neither of these headers get used by 
  $self-tx-remote_address. 
  
  What's the right way to retrieve the client's IP address? 
  
  In your case, that's $c-req-headers-header('X-Forwarded-For'); 



-- 
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: command in app directory

2014-07-14 Thread Jan Henning Thorsen
I would say it's a rather bad idea to store a module without an app prefix, 
like MyApp::Command::whatever. Also, modules that are lowercase is 
supposed to be used as pragmas: http://perldoc.perl.org/perlpragma.html

On Thursday, July 10, 2014 4:59:43 PM UTC+2, Tim wrote:

 Hi,

 is it possible to store a Mojolicious::Command in the same directory as 
 the Mojolicious::Lite app?

 This works

 push @{app-commands-namespaces}, 'commands';

  

 package commands:testcmd;
 use Mojo::Base 'Mojolicious::Command';
 ...


 This not

 push @{app-commands-namespaces}, '.';

  

 package testcmd;
 use Mojo::Base 'Mojolicious::Command';
 ...


 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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] Re: Wishlist thread (second edition)

2014-07-14 Thread Jan Henning Thorsen
About SSH tasks:
Have you looked at https://metacpan.org/pod/Mojo::IOLoop::ReadWriteFork? 
(Feedback wanted)

On Monday, July 14, 2014 4:11:08 PM UTC+2, Daniel Mantovani wrote:

 Thanks for the feedback, took a look at the code and I think it's a nice 
 way to integrate ssh tasks to Mojolicious. Not realy non-blocking in the 
 way Mojo::UserAgent is though, as far as I understood it uses one process 
 per ssh connection. (Mojo::UserAgent just runs inside the ioloop instead).

 El domingo, 13 de julio de 2014 21:12:01 UTC-3, bduggan escribió:

 On Saturday, July 12, sri wrote: 
- SSH and Telnet clients on Mojo::IOLoop (meaning non-blocking 
 clients). 
   Probably not very demanded requests, but in my opinion they would 
 help 
   developers to choose mojolicious as a base framework for apps that 
   concentrate several platforms with different interfaces (so you can 
 choose 
   using Mojo::UserAgent or for instance Mojo::SSHClient or 
 Mojo::TelnetClient 
   in a non-blocking way depending on what the target platform 
 supports). 
   
  
  Haha, this one is way way way way way out there... i'm not even sure a 
  non-blocking SSH client exists on CPAN yet. 

 We did something like this by using Mojo::Reactor-io to watch the output 
 of external ssh client processes : 

 https://metacpan.org/pod/distribution/Clustericious-Admin/bin/clad 

 Brian 



-- 
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: How to run in production mode?

2014-07-05 Thread Jan Henning Thorsen
I would say setting $app-mode(...) is a bad idea. You probably want to 
change the mode from the outside instead. Try setting MOJO_MODE before 
starting the application:

  MOJO_MODE=production ./script/yourapp daemon --listen http://*:3000

https://metacpan.org/pod/Mojolicious#mode

The operating mode for your application, defaults to a value from the 
MOJO_MODE and PLACK_ENV environment variables or development. Right before 
calling startup https://metacpan.org/pod/Mojolicious#startup,Mojolicious 
https://metacpan.org/pod/Mojolicious will pick up the current mode, name 
the log file after it and raise the log level from debug to info if it has 
a value other than development.
The only exception to the rule above is that hypnotoad set MOJO_MODE to 
production unless set to something else from the outside.


On Friday, July 4, 2014 8:13:35 PM UTC+2, Renato Forti wrote:

 Hi, All,

 How I can deactivate debug log of my server! Put it on production!

 I did try this:

 $self-mode('production'); # on lib/MyApp.pm

 But log continues like this:

 [Fri Jul  4 15:07:14 2014] [debug] Rendering template 
 PDDBx002-fav-pt-br.html.ep.
 Use of uninitialized value in string eq at template build.html.ep line 389.
 [Fri Jul  4 15:07:14 2014] [debug] Rendering template 
 PDDBx002-header-pt-br.html.ep.
 my variable $size masks earlier declaration in same scope at template 
 PDDBx002-header-pt-br.html.ep line 76.
 [Fri Jul  4 15:07:14 2014] [debug] Rendering template 
 auth-check.html.ep. Use of uninitialized value $did in string eq at 
 template auth-check.html.ep line
  15.
 Use of uninitialized value in string ne at template 
 PDDBx002-header-pt-br.html.ep line 9.
 [Fri Jul  4 15:07:14 2014] [debug] Template 
 PDDBx002-extended-page.html.ep not found.
 Use of uninitialized value $extended_page in string eq at template 
 build.html.ep line 406.
 [Fri Jul  4 15:07:14 2014] [debug] Rendering template 
 default-page.html.ep.
 [Fri Jul  4 15:07:14 2014] [debug] Template 
 PDDBx002-left-menu-default-pt-br.html.ep not found.
 Use of uninitialized value $left_menu_default_render in string eq at 
 template default-page.html.ep line 15.
 [Fri Jul  4 15:07:14 2014] [debug] Rendering template 
 left-menu-default-pt-br.html.ep.
 [Fri Jul  4 15:07:14 2014] [debug] Rendering template 
 PDDBx002-left-menu-pt-br.html.ep.
 [Fri Jul  4 15:07:14 2014] [debug] Rendering template 
 PDDBx002-pt-br.html.ep.Use of uninitialized value in string eq at 
 template PDDBx002-pt-br.html.ep line 13.

 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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Re: How to run in production mode?

2014-07-05 Thread Jan Henning Thorsen
I should probably also mention MOJO_LOG_LEVEL that you can set to your 
desired level:

 MOJO_LOG_LEVEL=info MOJO_MODE=production ./script/yourapp daemon --listen 
http://*:3000


On Saturday, July 5, 2014 8:52:49 AM UTC+2, Jan Henning Thorsen wrote:

 I would say setting $app-mode(...) is a bad idea. You probably want to 
 change the mode from the outside instead. Try setting MOJO_MODE before 
 starting the application:

   MOJO_MODE=production ./script/yourapp daemon --listen http://*:3000

 https://metacpan.org/pod/Mojolicious#mode

 The operating mode for your application, defaults to a value from the 
 MOJO_MODE and PLACK_ENV environment variables or development. Right 
 before calling startup https://metacpan.org/pod/Mojolicious#startup,
 Mojolicious https://metacpan.org/pod/Mojolicious will pick up the 
 current mode, name the log file after it and raise the log level from 
 debug to info if it has a value other than development.
 The only exception to the rule above is that hypnotoad set MOJO_MODE to 
 production unless set to something else from the outside.


 On Friday, July 4, 2014 8:13:35 PM UTC+2, Renato Forti wrote:

 Hi, All,

 How I can deactivate debug log of my server! Put it on production!

 I did try this:

 $self-mode('production'); # on lib/MyApp.pm

 But log continues like this:

 [Fri Jul  4 15:07:14 2014] [debug] Rendering template 
 PDDBx002-fav-pt-br.html.ep.
 Use of uninitialized value in string eq at template build.html.ep line 
 389.
 [Fri Jul  4 15:07:14 2014] [debug] Rendering template 
 PDDBx002-header-pt-br.html.ep.
 my variable $size masks earlier declaration in same scope at template 
 PDDBx002-header-pt-br.html.ep line 76.
 [Fri Jul  4 15:07:14 2014] [debug] Rendering template 
 auth-check.html.ep. Use of uninitialized value $did in string eq at 
 template auth-check.html.ep line
  15.
 Use of uninitialized value in string ne at template 
 PDDBx002-header-pt-br.html.ep line 9.
 [Fri Jul  4 15:07:14 2014] [debug] Template 
 PDDBx002-extended-page.html.ep not found.
 Use of uninitialized value $extended_page in string eq at template 
 build.html.ep line 406.
 [Fri Jul  4 15:07:14 2014] [debug] Rendering template 
 default-page.html.ep.
 [Fri Jul  4 15:07:14 2014] [debug] Template 
 PDDBx002-left-menu-default-pt-br.html.ep not found.
 Use of uninitialized value $left_menu_default_render in string eq at 
 template default-page.html.ep line 15.
 [Fri Jul  4 15:07:14 2014] [debug] Rendering template 
 left-menu-default-pt-br.html.ep.
 [Fri Jul  4 15:07:14 2014] [debug] Rendering template 
 PDDBx002-left-menu-pt-br.html.ep.
 [Fri Jul  4 15:07:14 2014] [debug] Rendering template 
 PDDBx002-pt-br.html.ep.Use of uninitialized value in string eq at 
 template PDDBx002-pt-br.html.ep line 13.

 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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


  1   2   >