The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2016-07-08

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:01 disputin joined #mojo
01:06 disputin joined #mojo
01:36 PopeFelix joined #mojo
01:52 disputin joined #mojo
02:02 jberger Reading the backlog, no I'm not using the license
02:45 chandwki when is it appropriate to stash something vs using a helper?
02:45 chandwki they can kinda be used for the same thing
02:46 jberger clarification, a helper can stash something, I think you are asking about a global/state helper versus using a per-request (stashed) value?
02:48 chandwki yeah
02:48 jberger the stash is useful any time you want to have a value or object or something stored for the duration of the request
02:49 chandwki so I am using helpers in templates to call methods on modules as part of my model, wasn't sure if I should be stashing those instantiated modules instead
02:49 jberger an app-wide "global" obviously lives longer than that
02:49 chandwki since helpers seem to be global
02:50 jberger it really depends on how you models work
02:50 jberger and your helper can be made to be per-request or app-global depending on how it works
02:51 jberger helper something_appwide => sub { state $dummy = initialize_something() };
02:51 jberger helper something_per_req => sub { shift->stash->{mysomething} ||= initialize_something() };
02:53 chandwki ok, so I am using helpers like the first appwide way... so does that mean once the module is instantiated it hangs around for multiple requests?
02:53 chandwki I was assuming it was instantiated for each request
02:53 chandwki first time using mojolicious
02:58 jberger no that will remain for multiple requests if you do it that way
02:58 jberger and sometimes you want that
02:58 jberger like database connections for example
02:59 jberger use whichever helper style is more appropriate for you
02:59 noganex joined #mojo
02:59 jberger also remember (if you are used to CGI for example) that the application lives longer than a single request
03:00 jberger so you have to think about globals
03:00 chandwki wrote a quick test that answered my own question :)
03:00 jberger state is basically a wrapper around a "my" in an outer scope
03:00 chandwki awesome, thanks for your help
03:00 jberger no problem
03:11 jberger I finally got a good surround photo (from today's hike) https://goo.gl/photos/UrumyiepEZeU9jao9
04:04 zivester joined #mojo
04:12 Quaii joined #mojo
04:42 inokenty-w joined #mojo
06:01 Mikey joined #mojo
06:07 dod joined #mojo
06:12 dod joined #mojo
07:11 AndrewIsh joined #mojo
07:13 Vandal joined #mojo
07:18 mpapec tempire: what presentation software did you use for
07:18 mpapec https://speakerdeck.com/tempire/intro-to-mojolicious-perl
07:25 sri most likely keynote
07:27 dod joined #mojo
07:34 roosterfeast Is there an easy way to ->render_later all requests that come in so I can make a request to another service for every incoming web request? I would like to retrieve user info from an API every time.
07:34 trone joined #mojo
07:53 jberger roosterfeast: you should be able to do that in an under
07:54 jberger Actually you could even get the user info in the under
07:54 jberger Them put it in the stash fir the endpoint to use
07:54 jberger *for
08:04 punter joined #mojo
08:16 osfabibisi joined #mojo
09:14 punter joined #mojo
10:00 Kripton joined #mojo
10:56 kaare joined #mojo
11:04 tchaves joined #mojo
11:10 blonewolfs joined #mojo
11:35 lari joined #mojo
12:02 kid51 joined #mojo
12:07 blonewolfs joined #mojo
12:14 nic nice photo, jberger
12:38 Zx3 joined #mojo
12:38 bwf joined #mojo
12:59 neilhwatson joined #mojo
13:04 cuechan joined #mojo
13:16 zivester joined #mojo
13:33 gizmomathboy joined #mojo
14:00 dvinciguerra_ joined #mojo
14:14 sri no laptop today :/
14:15 lluad joined #mojo
14:15 sri really odd this time
14:16 sri usually they just send it with ups from china to me
14:16 sri this time it's from the netherlands
14:16 sri and they sent a shipment notification two days before they handed the package to dhl
14:17 * sri shrugs
14:17 sri maybe it's just because it's prime vacation time all over europe
14:18 PopeFelix joined #mojo
14:22 sri maybe a detour to get the nsa firmware installed -.-
14:38 disputin joined #mojo
15:05 gtodd from a shell I can POST with curl  using an "empty" form like this:  curl --data '' http://watchout4snakes.com/wo4snakes/Random/RandomWord
15:06 gtodd how do I do that with M::UA ?    $ua->post("http://watchout4snakes.com/wo4snakes/Random/RandomWord" , {} ) ;
15:08 gtodd doesn't seem to work ... well I can't see a stringy rand word return value in there
15:11 sri where in the docs did you see that?
15:12 zivester joined #mojo
15:13 sri actually, ignore me, i don't have enough time atm.
15:14 Grinnz gtodd, an empty form is just... no content
15:14 gtodd doh  ... was using $ua = HTTP::Tiny->new() command line from earlier in the REPL  ... I knew it must be ... another obvious thing I'm doing incorrectly ... :-D
15:14 gtodd got it
15:16 gtodd it's $ua->post("http://watchout4snakes.com/wo4snakes/Random/RandomWord" , {} )->res->body
15:29 itaipu joined #mojo
15:33 dod joined #mojo
15:45 PryMar56 joined #mojo
16:03 webstrand joined #mojo
16:05 disputin joined #mojo
16:06 disputin joined #mojo
16:12 gtodd xdg: your lightning talk on boolean.pm  made me ☺ ☹ ... glad you caught it && sad there's threads ... I mean sad there's a bug
16:14 xdg gtodd, thanks.  I have a PR open: https://github.com/ingydotnet/boolean-pm/pull/14
16:14 xdg I may wind up asking for co-maint or something.
16:15 gtodd nice .. I was going to wait and then just post the timestamp of your talk from youtube
16:18 gtodd xdg: ++ for you work :)  there's a lot of those kind of small util type tools that really make perl nicer to use ... e.g. the *::Tiny ... Sawyer et. al.  Ref::Util might be one of those too
16:19 xdg Your note was a good prompt; I've emailed Ingy.
16:27 dod joined #mojo
16:29 gtodd xdg: btw, fiddling with HTTP::Tiny and Mojo::UserAgent too early this AM I mixed up the constructors $ua = HTTP::Tiny->new ... later Mojo::UserAgent->new ... and tried running these commands:
16:30 gtodd my $url = "http://watchout4snakes.com/wo4snakes/Random/RandomWord" ;
16:30 gtodd $uamojo->post( $url, {} )->res->body;   $uatiny->post($url, {} )->{content};  .... I'm pretty sure that last command has worked previously for a "post" but
16:31 gtodd I was running it against an IIS server that kept saying  "HTTP Error 411. The request must be chunked or have a content length"
16:34 sri gtodd: that hash does nothing
16:35 gtodd xdg: the only thing that worked was $uatiny->post($url, { headers => { 'content-length' => '0'} ,  })->{content};  ... the content-length was being set (automatically) but POST wouldn't work unless I explicitly set it to 0
16:36 jberger gtodd: in mojo that hash would have been headers anyway
16:36 gtodd sri: oops yes it's pleonastic :)
16:38 gtodd just wondering what does mojo UA send automatically in the headers that satisfies that server  ?
16:38 sri oh, my laptop is moving, now in amsterdam
16:38 xdg gtodd, I see a docs note that empty content doesn't set length/type headers automatically; not sure why.
16:39 xdg gtodd, please file a ticket so we can look into it eventually
16:39 gtodd anyway the workaround for $uatiny was to explicitly set content-length to "0" ... somehow it was getting an different length ...
16:39 gtodd xdg: OK
16:39 jberger gtodd: try MOJO_USERAGENT_DEBUG=1 to see the whole request/response on the mojo side
16:40 xdg it might be an IIS "feature"
16:40 jberger I'm not sure if http tiny or lwp have a similar mechanism but you could watch the wire if you have to
16:40 gtodd $uatiny was getting an automatically dry different length each time ... according to the server
16:41 gtodd xdg: yeah I noticed a few IIS discussion threads about chunking and  and content length that showed lots of client apps having problems (C# java etc.)
16:41 gtodd jberger: thanks
16:42 xdg from HTTP 1.1 spec: " If a request contains a message-body and a Content-Length is not given, the server SHOULD respond with 400 (bad request) if it cannot determine the length of the message, or with 411 (length required) if it wishes to insist on receiving a valid Content-Length."
16:42 sri maybe take this discussion somewhere else?
16:42 gtodd sri: :)
16:43 gtodd sri: since it was using mojoUA as an examplar it was barely on topic ... anyway over and out :)
17:08 ptolemarch I'm creating a systemd unit file to run a Minion application.
17:08 ptolemarch Do I want Type=simple or Type=forking (or...)
17:14 waveform joined #mojo
17:15 waveform Anyone know of a Mojolicious image re-sizing proxy?
17:18 disputin joined #mojo
17:22 jberger waveform: I'd probably use Imager from CPAN and if you need to unblock it then either Minion or Mojo::IOLoop::ForkCall depending on the immediacy of the response that you need
17:23 jberger ptolemarch: the main process in minion is just a regular process, runs in the foreground
17:24 jberger I'm guessing that that is all it is asking about
17:24 jberger But I don't know systemd enough to tell you that for sure
17:24 ptolemarch jberger: Thank you, that does seem to answer it.
17:24 jberger Cool
17:24 vicash waveform: you should sandbox/jail the image resizing for security reasons. so better to use Minion/ForkCall plugin to handle it
17:25 jberger vicash: meaning for DDOS prevention?
17:25 jberger I'm not sure what you mean
17:26 vicash jberger: no. more like vulnerabilities like those of ImageMagick that were discovered a month back or so.. image uploaded can be malicious
17:26 waveform It will run in docker. It's only for development anyway, In production I'll probably use Cloudinary.
17:27 jberger Imager didn't use ImageMagick,indeed that is one of its best features
17:27 waveform Thanks for feedback. I'll get to work. If I create anything worthwhile I'll share it here.
17:28 waveform Bugs are occasionally found in libpng, etc. Imager is not immune to those/
17:41 jberger Of course not, but IM has been notoriously problematic forever
17:42 disputin joined #mojo
17:46 disputin joined #mojo
18:11 punter joined #mojo
18:26 itaipu joined #mojo
18:30 berov joined #mojo
18:32 punter joined #mojo
18:34 noganex_ joined #mojo
18:42 tchaves joined #mojo
18:56 asarch joined #mojo
19:11 sri oh, this is funny, the vector design app i use on os x has just been released for windows... so i guess i would have gotten away with a windows laptop too ;p
19:13 disputin joined #mojo
19:13 itaipu joined #mojo
19:27 marty joined #mojo
19:32 lluad joined #mojo
19:33 vmvm joined #mojo
19:37 lluad joined #mojo
19:38 marcus sri: but then you would have had to use windows ...
19:38 sri windows 10 is not so bad
19:39 Zen did they get rid of the registry yet?
19:42 dod joined #mojo
19:42 vmvm hello, help me please!! i'm not understand how to start minion worker in production, can I start it in main app when use hypnotoad? or it can be start only with command myapp.pl minion worker ? how to start it in background? with & ? or existing better way? thank you
19:44 preaction vmvm: myapp.pl minion worker is how you start a minion worker yes. if you want to background it, you can do & yes, or you can use something like Daemon::Control or your system's init daemon (like init or systemd)
19:44 bpmedley vmvm: howdy, are you trying to start at boot, or from the cli?
19:47 vmvm at boot and from cli ) now I'm starting minion with & but I think this is wrong ( what if I want start 5-10 workers ?
19:48 sri you don't, one worker can handle multiple jobs concurrently
19:48 vmvm is it possible to start workers from main  app?
19:48 bpmedley vmvm: what os/distro?
19:48 vmvm ubuntu
19:49 vmvm 16.04
19:49 disputin joined #mojo
19:50 bpmedley Sorry, i only have experience with centos 6 and i'm at work
19:51 sri and no, you can't start a worker with the app
19:51 sri although, i guess that capability could be developed
19:52 vmvm ok, I'm starting one worker at boot with &, how can I be sure that it will not fail?
19:52 preaction with a monitoring system. some init systems (supervisord, systemd) provide one
19:56 vmvm thanks to all , I did not find this in the documentation , so the doubt . I really do not understand why there is no option -daemon for example
20:00 sri because most init systems actually like to handle that themselves
20:01 sri daemonizing is also hard to test, so an easy decision to leave it out
20:01 preaction and it's kind of tricky/annoying to get perfectly right for all systems, so in the interest of "Do one thing well" and "DRY", better to leave it to the OS to do
20:02 vmvm ok, thank you for help ))
20:02 sri the start a worker from the app server thing keeps coming up, i guess that would be nice to have
20:03 sri if i had more time i guess i'd give it a shot
20:04 vmvm Sebastian! thank you for your work! ))
20:17 vmvm left #mojo
20:29 disputin joined #mojo
20:31 bpmedley https://github.com/brianmed/ForkAndGo/blob/master/eg/minion.pl  <-- i have a plugin for that; however, it's not been tested much
20:33 itaipu joined #mojo
21:14 itaipu joined #mojo
21:54 berov joined #mojo
22:12 dvinciguerra_ joined #mojo
22:42 gtodd joined #mojo
23:26 kid51 left #mojo
23:30 cuechan joined #mojo
23:42 sri wow, utopia reminds me a little bit of mr robot
23:47 meshl joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary