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

IRC log for #mojo, 2016-03-30

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

All times shown according to UTC.

Time Nick Message
00:00 jontaylor joined #mojo
00:34 bpmedley https://github.com/kraih/mojo/compare/master...brianmed:master <-- thoughts on this approach for an auto launching minion?
00:44 Grinnz LOL http://vanilla-js.com
00:46 meshl joined #mojo
01:23 PanzerBjorn joined #mojo
01:24 PanzerBjorn Were there fairly significant changes to routes between Mojo 4.x and 6.x? I recently upgraded and can't get about half of my routes (routes with placeholders) working anymore.
01:24 bpmedley PanzerBjorn : https://github.com/kraih/mojo/wiki/Upgrading
01:24 PanzerBjorn I reviewed the docs and adjusted my routes to match the 'current look and feel' but they're just 404ing.
01:25 bpmedley PanzerBjorn : Do you have a smallish example?
01:25 PanzerBjorn Sure, let me give you one real quick.
01:26 PanzerBjorn $b->route('/class/:id', [id => qr/^[0-9]+$/])->to('class#view', namespace=>'Classifieds')->name('viewclass');
01:26 PanzerBjorn $b is an under().
01:27 bpmedley PanzerBjorn : Would you make a lite app with that?
01:27 PanzerBjorn No, I wouldn't. This is for a major site. Hundreds of routes, a couple dozen controllers, each with multiple actions.
01:28 bpmedley I'm only asking for an example app for testing.
01:29 PanzerBjorn Making a Lite app to proof something wrong with a non-Lite app seems counter-productive. Plus I don't recollect how Lite apps work since I've been working in non-Lite for years.
01:29 bpmedley Fair enough.  Perhaps a small gist with just the startup method.
01:30 mattp_ PanzerBjorn: https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Routing.pod#Restrictive-placeholders
01:31 mattp_ current docs looks equivalent to what youve pasted, so perhaps a bug
01:31 asarch joined #mojo
01:31 mattp_ what does routes -v output?
01:31 PanzerBjorn If I remove the [id => qr/.../] portion it works as expected.
01:32 PanzerBjorn Oh lawdy, I see the issue now. Semantics for the loss.
01:33 bpmedley May I ask what the issue was?
01:33 PanzerBjorn $b->route('/class/:id', [id => qr/^[0-9]+$/])01 should be:
01:33 PanzerBjorn $b->route('/class/:id' => [id => qr/^[0-9]+$/])01
01:33 PanzerBjorn And in my existing code used to be:
01:33 PanzerBjorn $b->route('/class/:id', id => qr/^[0-9]+$/)01
01:34 PanzerBjorn Confusing change, I imagine there was a good reason for it though. Can't imagine what, but must have been important.
01:36 mattp_ ah haha
01:36 PanzerBjorn Never a dull moment with Mojo.
01:37 PanzerBjorn =)
01:38 Grinnz the first two look identical unless i'm missing something
01:38 PanzerBjorn The first one is a comma-separated list of elements, the second is assigning a list to the route path.
01:39 PanzerBjorn Via hash constructor.
01:39 Grinnz there's no assignment or hashes there
01:39 Grinnz => is just a fat comma
01:39 meshl joined #mojo
01:39 PanzerBjorn 'val1', 'val2'  versus 'val1' => 'val2'
01:39 Grinnz yes, those are identical
01:39 PanzerBjorn Great, should have worked then! But it didn't.
01:40 mattp_ PanzerBjorn: the => shouldnt changea nything, but removing the [] obviously would. which did you mean fixed it?
01:42 PanzerBjorn It appears to have fixed things, yes.
01:46 PanzerBjorn Well, you can't do one without the other, so... Once I changed the commas to => badda-boom, routes resolving again.
01:46 PanzerBjorn Ya know, along with the [] changes.
01:46 PanzerBjorn Because the [] seems to now be necessary.
01:46 PanzerBjorn Hmmm, not all the routes got fixed.
01:47 ilbot2 joined #mojo
01:47 Topic for #mojo is now 🍻 cheers | http://mojolicious.org | http://irclog.mojolicious.org | http://code-of-conduct.mojolicious.org
01:47 PanzerBjorn But the simpler one results in a 404
01:48 Grinnz with what url to test?
01:49 PanzerBjorn I'm testing on an internal staging server. On a private net.
01:49 Grinnz i mean, what path
01:50 PanzerBjorn https://example.com/class/2134.html
01:50 Grinnz oh, remove the ^ and $
01:50 Grinnz https://metacpan.org/pod/Mojolicious::Guides::Routing#Restrictive-placeholders
01:51 PanzerBjorn lol - Really? I just added those because I saw the ones that were there and want "Crap! Someone could try to hack non-numerics in there, think about the exploits!"
01:51 PanzerBjorn Thank you mandatory corporate web security training certifications.
01:51 Grinnz iirc, the regex has to match the whole parameter, so it's virtually anchored
01:52 PanzerBjorn Got it, thanks.
01:52 Grinnz either way you can test and find out ;)
01:52 PanzerBjorn Doing that now, will let you know.
01:54 PanzerBjorn Hmmm, nope. 404s.
01:55 PanzerBjorn Take the => [id = qr/[0-9]+/] out and it works fine.
01:55 PanzerBjorn id => rather
01:57 bpmedley Can you use (?!\D) instead of ^[0-9]+$
01:58 Grinnz uhm, why
01:58 PanzerBjorn What would that look like in this line? $r->('/test/:id' => [id => qr/[0-9]+/])
01:58 bpmedley Moment
02:00 jberger I thought the route method was removed too
02:00 PanzerBjorn There's no chance that the Routing Guide on mojolicious.org is out of date, is there? *ducks*
02:00 * jberger looks
02:00 PanzerBjorn According to the docs, route() is still there.
02:00 Grinnz oh i didn't even notice it was ->route, yeah that should be something else
02:01 jberger http://mojolicious.org/perldoc/Mojolicious/Routes/Route#route
02:01 Grinnz you want ->any or ->get etc
02:01 jberger It isn't removed but it is documented as low level which usually means that users shouldn't need it
02:02 Grinnz it also has different syntax from the normal routing methods
02:02 PanzerBjorn Hmmm, should I use any() instead?
02:02 jberger Probably
02:03 bpmedley PanzerBjorn : qr/\A\d+\z/ <-- Can you use that instead of the ^$ for verifying only numbers are passed to the controller?
02:05 bpmedley Grinnz : I was asking about the qr above so that non-numerics won't be passed.
02:05 Grinnz bpmedley, the point is not to avoid ^$, it's to avoid anchors
02:05 Grinnz as the documentation says
02:05 Grinnz also, [0-9] is better to use than \d
02:06 PanzerBjorn \d matches weird stuff sometimes.
02:06 Grinnz depending on perl version, it can match unicode digits
02:06 bpmedley Am I mis-reading?  The document says: 'just make sure not to use ^ and $'
02:06 Grinnz yes, then it says *why*
02:06 PanzerBjorn ]0-9] always matches positive whole integers which is always what you want for DB indexes.
02:06 bpmedley So, that's why I'm asking.. is \A and \z acceptable instead of ^$?
02:06 Grinnz no.
02:07 jberger bpmedley: it becomes part of a larger regex
02:08 jberger So you can't match the absolute beginning and end of a string
02:08 jberger Just like you can't match the beginning and end of a line
02:09 PanzerBjorn Okay, the any() change appears to be working... so far.
02:11 PanzerBjorn Alright, now to replace all references to render_static in the site... Good gods that's going to be a lot.
02:13 jberger PanzerBjorn: or just make a render_static helper
02:13 jberger ;)
02:13 PanzerBjorn $c->reply->static is already a helper.
02:14 jberger So?
02:14 PanzerBjorn Sew buttons.
02:14 Grinnz helpers can help helpers!
02:14 PanzerBjorn I'm not sure the two are compatible enough to make one easily wrappable.
02:16 PanzerBjorn Ah, okay. Seems they ARE compatible. Simple enough, time to help the helper.
02:18 PanzerBjorn I've always loved the $self->helper() convention, it sounds very Stuart Smalley.
02:23 bpmedley ^/((?^:[0-9]+))/?(?:\.([^/]+))?$  <-- I assume this is the r.e. in question that the documentation is referencing?  This r.e. is shown via "routes -v".
02:26 PanzerBjorn It doesn't say in the docs, but can $c->reply->static() not be given an absolute file path? I tried passing it a full path beginning with / and the production.log seems to be trying to find it relatively instead.
02:26 bpmedley PanzerBjorn : This may be helpful: http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Serving-static-files
02:27 PanzerBjorn Danke
02:27 PanzerBjorn Huh, that really doesn't clarify it.
02:27 bpmedley $c->res->content->asset(Mojo::Asset::File->new(path => '/etc/passwd'));  <-- Does this work?
02:28 Grinnz it can only be relative to the homedir as far as i know
02:28 bpmedley $c->reply->asset(Mojo::Asset::File->new(path => '/etc/passwd'));  <-- might be easier, wrong copy 'n paste
02:28 PanzerBjorn The documentation for $C->reply->static also says you can use ../ to go up the path tree, but nothing about absolute file paths. Neither does the link you gave mention absolute.
02:28 bpmedley Does the reply->asset work?
02:29 PanzerBjorn @Grinnz: is the public folder typically the homedir in a standard/stock Mojo app?
02:29 Grinnz it's public/ in the base dir by default
02:30 Grinnz https://metacpan.org/pod/Mojolicious::Static#paths
02:30 PanzerBjorn Awesome, thanks. Then I can just ../../.. my way up the tree. ;)
02:30 bpmedley $c->reply->asset(Mojo::Asset::File->new(path => '/etc/passwd')); <-- Does this work?
02:30 bpmedley http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Custom-responses
02:31 PanzerBjorn That doesn't really seem... Efficient. Why would I want to create an in-memory asset when the goal is to bitdump a file from disk/cache?
02:41 bpmedley PanzerBjorn : http://mojolicious.org/perldoc/Mojo/Asset/File#get_chunk <-- Seems to use this.  Don't quote me on that, though..
02:47 noganex_ joined #mojo
02:47 bpmedley PanzerBjorn : I'm testing serving a 7GB file w/ about 23 MB of ram used, it seems
02:49 PanzerBjorn Well, ../../.. worked and it was really simple.
02:56 jasanj joined #mojo
02:57 jasanj what's the difference emit_hook and emit in Mojolicious::Plugins ?
02:58 jasanj seems they are doing the same thing
03:12 jawnsy joined #mojo
03:12 jawnsy hey, what's the best way to run a Mojolicious app in production?
03:12 jawnsy like in terms of recommended web server
03:23 s1037989 jawnsy: Most people use hypnotoad for the web server, and usually put it behind a reverse proxy most often nginx
03:27 jawnsy hmm, alright
03:28 jawnsy any recommended nginx settings?
03:28 jawnsy or what advantages does nginx in front have over just going directly to hypnotoad? I assume it's just used for caching and stuff like that
03:29 jawnsy is there a decent guide somewheres?
03:30 s1037989 jawnsy: caching, yes...  I think probably the biggest reason is for virtual hosts, say e.g. some of your site is php or something...  Anyway, I can't speak too much to the why.  I have a server where hypnotoad is the server open on the public port.  I like it just fine.  :)
03:30 jberger jawnsy: yes, in the guides :p
03:30 jawnsy I'm lazy, I want you guys to do my reading/googling for me :(
03:31 jberger Now now, that's no fun
03:31 jawnsy s1037989: ok that sounds like a good option (because I'm lazy) :D
03:31 jberger Try the cookbook
03:31 s1037989 jawnsy: http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Nginx
03:31 jawnsy hey, if it makes you feel any better, it's because I want to make Mojolicious easily runnable on OpenShift :D
03:31 jawnsy although it also makes me wonder if we should update the Debian package as well
03:32 jberger jasanj: hooks are basically events in the request cycle that are more
03:32 jberger ... global
03:32 jawnsy <3 thank you s1037989
03:32 * s1037989 nods
03:32 jawnsy Perl people are nice people :)
03:32 jberger I'd say it would be rather rare to want to emit_hook on your own
03:33 jberger At least not until you are very accustomed to hooks
03:34 jberger jawnsy: awwww
03:36 jberger jasanj: put it another way, I've literally never used emit_hook
03:36 jberger I use emit all the time
03:36 jberger If that counts for something
03:36 jawnsy jberger: also, hey, haven't talked to you for awhile sir ^_^
03:37 jawnsy not since you tried to get me a job in Chicago :D ... but that relationship ended so now I'm in sunny California
03:44 jasanj jberger: actually I don't understand the difference with 'hook' and 'on' too
03:45 jasanj sub hook { shift->plugins->on(@_) }
03:46 jasanj 'hook' just transfer the event to plugins
03:55 csson joined #mojo
03:55 jberger jawnsy: cali sounds nice
03:56 jberger What are you doing out there?
03:56 jberger jawnsy: ^^
03:57 jberger jasanj: I'm not exactly sure why the hook subscribers are stored on the plugin object but that really doesn't make a difference
03:57 jberger Anyway these are the defined hooks
03:58 jberger http://mojolicious.org/perldoc/Mojolicious#HOOKS
03:58 jberger Maybe seeing them listed is useful to help you understand
04:19 inokenty-w joined #mojo
04:21 irqq joined #mojo
04:22 jawnsy jberger: I work for Red Hat on OpenShift :-D
04:22 jawnsy jberger: I live in Mountain View now
04:24 jawnsy jberger: add me to the LinkedIn ---> https://www.linkedin.com/in/jawnsy
04:25 jawnsy jberger: OpenShift is a platform-as-a-service based on Docker and Kubernetes. I've been trying to make applications written in different languages/frameworks easily runnable on our platform, so I figured I'd look at doing that for Mojolicious
04:27 jberger jawnsy: cool
04:30 jawnsy yeah it's pretty awesome, working with some exciting tech, enjoying great weather
04:31 jawnsy it never snows here :D
04:38 s1037989 jawnsy++  Awesome!  Do that!  I use cloud9 for a lot of my development...  They have python, node, php templates...  no Perl, no Mojo.  We need more platforms supporting Perl / Mojo, so I think it'd be great if you support and document Perl / Mojo in OpenShift!
05:10 PanzerBjorn RedHat's here in the bay area?
05:13 irqq joined #mojo
05:24 Shaeto joined #mojo
05:54 PanzerBjorn Hmmm, guess $c->paramhash also went byebye.
05:55 PanzerBjorn No mention thereof in the upgrading document.
05:56 PanzerBjorn Doh, that's a local helper, m'bad.
06:00 PanzerBjorn Ugh, so the syntax has changed there after all... I need to use $params->names, so how do you get a handle on a Mojo::Parameters object from the $c controller object?
06:07 PanzerBjorn So a dump of $c shows I can access it via: $c->tx->req->params->names - is that proper or is there a better shortcut? It feels kind of low-level to access the params that way.
06:10 Shaeto1 joined #mojo
06:19 Shaeto joined #mojo
06:24 anparker PanzerBjorn: You can drop "tx" part. https://github.com/kraih/mojo/wiki/Upgrading#parameter-name-listing
06:25 PanzerBjorn Good to know, thanks.
06:44 osfabibisi joined #mojo
06:44 batman "use of Mojolicious?" -- https://github.com/jhthorsen/json-validator/issues/17
06:44 batman sigh
06:46 PanzerBjorn Heh
06:47 PanzerBjorn I didn't know Mojo had built-in LWP-like capability. I learned something new.
06:47 batman sri or anyone else: ^^ let me know if you have any more i can use as arguments
06:47 batman PanzerBjorn: Mojo::UserAgent ..?
06:48 PanzerBjorn Yeah, never looked into that, didn't really know it was there. I've been using LWP for 20 years for crawlers and web scraping.
06:50 PanzerBjorn Mojo::UserAgent is comparable? I.e. supports custom headers, cookie jars, MIME/multipart, service hacks, etc?
06:50 PanzerBjorn (Auto-follow, controlled follows, etc.)
06:58 batman it supports probably all you need.
06:59 batman and it's incredible much faster (especially for crawling) if you write non-blocking code.
07:04 deserted joined #mojo
07:19 AndrewIsh joined #mojo
07:20 trone joined #mojo
07:27 deserted joined #mojo
07:42 PanzerBjorn The blocking isn't a bad thing for most crawlers since you need to enforce throttling anyway - if you request too many pages too quickly it pisses sysadmins and webmasters off.
07:43 PanzerBjorn So you usually use blocking calls with a 500-1500ms delay between requests anyway.
07:43 PanzerBjorn If you want to be a good neighbour. ;)
07:44 batman that's weird... i would probably crawl in parallell per domain or something.
07:45 PanzerBjorn Assuming you're crawling multiple domains, sure. I have a separate daemon per site.
07:58 mdom Is there a way to attach a error message to a failed validation? $c->validation->optional('password')->in('foo') results in the error fields [ 'password','in','foo' ]. I currently add a check password_identical => sub { ... } that does the same as 'in', just to get the more descriptive validation name
08:05 sugar joined #mojo
08:06 Vandal joined #mojo
08:12 bpmedley batman : https://github.com/kraih/mojo/compare/master...brianmed:master <-- Have any thoughts on the code here?
08:33 bpmedley PanzerBjorn : Mojo::UserAgent even supports WebSockets from the CLI.
08:35 PanzerBjorn Very nice. =)
08:50 orev1 joined #mojo
08:53 PanzerBjorn left #mojo
09:07 meshl joined #mojo
09:12 irqq joined #mojo
09:17 kivilahtio Mojolicious it is very nice :)
09:18 bpmedley kivilahtio++
09:43 jontaylor joined #mojo
09:44 sebbe joined #mojo
09:53 batman bpmedley: it looks very fragile.
09:53 bpmedley batman : Thanks for looking.  Would you elaborate?
09:53 batman in the context of prefork/hypnotoad i would just tell the user to start minion by itself
09:54 batman what i would do in the simple case is to limit myself to daemon
09:55 bpmedley That sounds like difference of opinion at the workflow level versus being technically fragile.  I see your point; however, I wonder if I should look into adding to the daemon server.
09:57 batman so... how do you handle when INT fail to be sent to the minion worker?
09:57 bpmedley When would INT fail?
09:58 batman there's a bunch of edge cases
09:58 bpmedley Example?
09:58 batman saying "kill INT won't fail" makes me unable to continue the discussion
09:59 bpmedley I'm not saying kill INT won't fail.  I'm asking you to be specific.
10:00 nic on a box under high load interrupts can be dropped
10:00 nic the common fail case is the sender doesn't have privs, but maybe that doesn't happen in your scenario
10:00 bpmedley nic: That's understandable.  If the interrupt is dropped, then what can be done?
10:01 batman bpmedley: the question is not what can be done. the question is how does your code handle that.
10:01 batman from what i can read the answer is "it doesn't"
10:02 nic the second most common case is the receiver just isn't able & willing to receive, but again that might not occur in your scenario
10:02 bpmedley nic : When you say "isn't able" are you referring to having no signal handler in place?
10:03 nic nope
10:03 nic I'm talking about transient state
10:03 bpmedley Ok, so would you elaborate more pls?
10:03 nic read up on process states
10:06 dod joined #mojo
10:07 mishanti1 states are... iffy. On a good day. Handling interrupts properly need not be hard, but should be carefully considered.
10:08 bpmedley mishanti1 : Thanks for the response, can you quantify further?
10:11 dod joined #mojo
10:16 mishanti1 bpmedley: I often see the explicit ignoring of signals in code. A common case is the developer wanting a write()-call to be uninterruptable. Another thing I often see is ignoring signals when handling signals, so as to avoid race-conditions.
10:17 mishanti1 bpmedley: And then as nic mentioned there is the load-issue and the whole mess of how the different kernel schedulers do things.
10:25 mishanti1 bpmedley: Yeah, and then there is Windows.
10:27 bpmedley mishanti1 : I see your point, I think.  However, how does ignoring signals factor into this scenario?
10:27 bpmedley Also, this code is linux/unix only.
10:27 dvinciguerra__ joined #mojo
10:29 mishanti1 bpmedley: I have not looked at the code in question (as I perhaps should have). Just commented generally. Can have a look at it later though.
10:29 bpmedley mishanti1 : Would be sweet if you could peruse.. :)
10:36 mishanti1 bpmedley: Ok, so I opened it in a tab here and noticed that the signals are only sent to the process once (eg `kill 'QUIT', $pid`) in Hypnotoad.pm , without looking at processes affected.
10:38 mishanti1 So signals sent might not even be received on the other end. Btw: I have not looked at perl's c code for signals, so it might be that `kill` handles that, and I just don't know it.
10:42 bpmedley mishanti1 : Sure, what I heard you say is that the finalization procedure should detect if the Minion process is still alive (perhaps via kill 0) after sending an INT signal?   And, if so, retry the kill a few times?
10:43 dotan joined #mojo
10:43 nic The common pattern on unix/linux is to have backoff intervals and int escalation
10:43 mishanti1 bpmedley: Something along those lines perhaps. As a side-note: I know very little about these things, and someone who has worked in more detail should weigh in.
10:44 mishanti1 bpmedley: I believe mst has done something in Daemon::Control for checking that a process is actually killed etc.
10:44 nic If you can determine (read) the configured timeout values then you can set appropriate backoffs
10:46 nic Why do I have abs no trouble picturing mst killing something that doesn't want to die?
10:46 mishanti1 bpmedley: As a side-note: if you want to sleep at night then don't start reading about signals and wakeup latency in the different linux schedulers. There be dragons.
10:47 bpmedley nic , mishanti1 : I see your point.  However, when these backoff intervals are used then that's because the first signal was never delivered, right?
10:47 mishanti1 nic: Killing something until it dies of it you mean? :)
10:47 mishanti1 bpmedley: never delivered or ignored. I don't think you can know.
10:51 bpmedley In this scenario, if the signal was never delivered, then the most probable cause would be a box under heavy load, is that correct?
10:59 bpmedley be back later
11:01 kaare joined #mojo
11:08 meshl joined #mojo
11:10 csroli joined #mojo
11:30 kivilahtio How can I know which plugins has the Mojolicious $app already loaded?
11:31 batman kivilahtio: you can't
11:31 batman you can however check if a helper is registered
11:32 batman like in assetpack i do: return if $app->renderer->helpers->{asset};
11:35 odc joined #mojo
12:14 glauber joined #mojo
12:25 Lee joined #mojo
12:43 dvinciguerra__ joined #mojo
12:45 neilhwatson joined #mojo
13:42 asarch joined #mojo
14:30 marty joined #mojo
14:30 marty joined #mojo
14:31 lluad joined #mojo
14:39 csroli joined #mojo
14:39 dod joined #mojo
14:52 jontaylor joined #mojo
15:13 janus joined #mojo
15:14 sri batman: ouch, what an annoying issue
15:14 sri but yea, LWP is bigger than Mojolicious
15:15 sri looks like you didn't address how he thinks Mojolicious uses LWP behind the scenes
15:19 batman does he..?
15:19 * batman reads again
15:20 sri "I'm sure Mojolicious uses similar packages in the background."
15:20 batman right. commenting now...
15:21 sri goes to show we shouldn't have ignored advertising the toolkit aspect for so many years
15:22 sri on the plus side, i don't have to defend reinventing wheels anymore
15:22 sri that was really annoying the first 3 years :)
15:22 genio PR #943 looks good to me
15:23 batman sri :)
15:24 nicomen reinventing rounder wheels ;)
15:24 sri re #943, didn't i say no more semicolon patches recently?
15:25 Grinnz_ batman: not to disagree but just to comment on your comments ;) Cpanel::JSON::XS does have the number/string logic in recent versions, and File::Slurper should be used not File::Slurp
15:25 nicomen or Path::Tiny ...
15:25 nicomen or just use the Mojolicious toolkit ;)
15:26 sri the whole idea that he wants another toolkit like LWP is funny
15:26 * batman just made another comment on https://github.com/jhthorsen/json-validator/issues/17
15:27 batman Grinnz_: same number/string logic as Mojo::JSON ?
15:27 Grinnz_ yes
15:27 batman ok. thanks
15:27 Grinnz_ there was a PR to bring it to JSON::PP but we know how that dist is maintained :P
15:28 bobkare joined #mojo
15:28 nicomen http://widgets.stratopan.com/wheel?q=libwww-perl-6.15&amp;fs=1 vs http://widgets.stratopan.com/wheel?q=Mojolicious&amp;fs=1
15:28 sri right, Cpanel::JSON::XS is pretty nice now
15:39 batman huh? does Mojolicious have a dependency..?
15:39 batman oh. only in older perls, right?
15:39 jberger batman: yeah
15:39 batman \o/
15:39 jberger that's a core module as of 5.20
15:40 jberger stratopan probably analyzes with a <= 5.18 would be my guess
15:40 genio nicomen: ooooh.  that's a neat tool
15:40 Grinnz_ you actually need 5.22 for a new enough version of IO::Socket::IP
15:41 Grinnz_ there was some bugfix iirc
15:41 sri maybe i should add something about this to the contributing guide https://github.com/kraih/mojo/pull/943#issuecomment-203494716
15:41 jberger haarg: first bug filed: https://rt.cpan.org/Ticket/Display.html?id=113455&amp;results=ba43f4482e648fd350c48df77f91554b
15:41 sri tiny patches with 3-4 new commas or so are really annoying
15:41 sri if someone was to give all guides a professional review, that would be something else
15:42 PryMar56 joined #mojo
15:43 genio jberger: may want to update it with a title
15:43 genio err, subject
15:43 Dandre joined #mojo
15:44 jberger argh, I hate RT
15:44 jberger how do I do that?
15:45 genio I might be misremembering (over a year since we switched from RT internally).  Open the ticket, at the top right, there should be a drop-down of sorts to allow editing
15:46 jberger got it
15:46 jberger it wasn't clear at all that those links allowed editing
15:46 genio Yea, RT served us well for quite a while here at work, but it's just... eww
15:47 jberger anyway, another one: https://rt.cpan.org/Ticket/Display.html?id=113456&amp;results=d73a2362776946d3f46cdf9c9640d975
15:48 genio They should really fix the copyright on Object::Simple as well.
15:48 good_news_everyon joined #mojo
15:48 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vVO3f
15:48 good_news_everyon mojo/master ddbb0da Sebastian Riedel: mention overly simplistic doc changes
15:48 good_news_everyon left #mojo
15:50 sri that doesn't mean no typo fixes, but please do it big scale, at least covering the whole file
15:51 genio line 66 seemingly has an errant comma in your last commit
15:51 jberger genio: good point
15:51 jberger mentioned that in the third bug report: https://github.com/iakuf/AnyEvent-Emitter/issues/1
15:51 jberger will update the others as needed
15:58 sri Catalyst is 8k lines actually
15:58 sri same size as Mojolicious
15:59 pink_mist huh, I expected it to be rather a bit larger
16:00 batman sloccount catalyst-runtime/lib/ # 6870
16:00 jberger 4th issue filed: https://github.com/miyagawa/Data-Section-Simple/issues/6
16:00 good_news_everyon joined #mojo
16:00 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vVOZX
16:00 good_news_everyon mojo/master 4546d77 Sebastian Riedel: fix a few typos
16:00 good_news_everyon left #mojo
16:01 jberger I think I'm going to draw the line at stand-alone module forks
16:01 jberger there are some forked modules that are part of larger projects and I just don't quite care as much about those
16:02 sri batman: oops, wrong channel
16:02 batman sri :)
16:03 sri batman: but i use cloc instead of sloccount
16:03 sri since it's more precise in my experience
16:03 disputin joined #mojo
16:03 sri which says 8474 lines
16:03 sri in lib
16:03 batman ok
16:04 pink_mist oh right, now I realise why I thought Catalyst would be larger; it uses Moose, so technically that adds a huge number of lines of code every time you run a catalyst app ... was more thinking of the number of lines of code being run rather than the number being maintained by the specific project
16:05 sri Moose is like 16k lines of code ;p
16:05 sri twice as big as Mojolicious
16:05 pink_mist exactly :P
16:05 batman pretty crazy
16:05 batman pink_mist: and plack
16:06 jberger and all the HTML:: modules etc
16:06 genio Perl is GPL 1 and Artistic 1?
16:07 Grinnz_ GPL 1+
16:13 kes joined #mojo
16:20 sri oh noes, what have you americans invented this time? https://twitter.com/kyleayers/status/714835753138696192
16:21 genio The only thing one should visit an Arbys for is their curly fries.
16:21 Grinnz_ Thats even more confusing because of all the contexts where fish isn't considered a meat
16:35 jberger reminds me of Wyngz
16:36 disputin joined #mojo
16:37 jberger http://www.cc.com/video-clips/2ucxw7/the-colbert-report-thought-for-food---wyngz---wal-mart
16:41 batman is there any easy way to implement something like $emitter->on("user:batman:*", sub { my ($emitter, $event, $data) = @_; .. }); ?
16:41 jawnsy s1037989: we have a Perl template but idk how good it is... of course the version that OpenShift Online (the cloud service) is running is version 2 (cartridges, gears, etc) and version 3 is very different (built on top of Kubernetes and Docker)
16:42 batman the alternative i see is simply to put the $event name inside $data and just subscribe to "user:batman" events
16:42 batman not sure what makes sense...
16:50 jberger batman: I did something similar in Minion::Notifier
16:50 jberger if you want to take a peek
16:51 batman jberger: inside setup_listener() ?
16:52 jberger I'll have to look to remember
16:52 batman no worries.
16:52 jberger wait no, nevermind
16:52 jberger I missed the *
16:52 jberger I made a catchall event and emit it too
16:52 batman right. i smell bad design from my part :)
16:52 batman yeah, sounds sane
16:52 jberger but you want a halfway where it is user events but only for a given user
16:53 batman yeah, but i can just do $obj->emit("user:batman" => $event_name => @data);
16:53 jberger Mercury does some similar things too (kinda)
16:53 batman looks cleaner and faster
16:53 jberger I wonder if it would be handy to have some generic bus subscriber with like topics
17:00 cpan_mojo Devel-StackTrace-Extract-1.000000 by MAXMIND https://metacpan.org/release/MAXMIND/Devel-StackTrace-Extract-1.000000
18:08 asarch joined #mojo
18:10 jberger That's interesting
18:11 jberger Develop requires is enough for cpan_mojo to catch it
18:13 sri so, if everyone uses ->trace to store the stacktrace, why don't we?
18:14 jberger we had that whole discussion a while back
18:14 jberger I don't recall all the arguments but I do remember that we decided not to change anything
18:14 * sri doesn't remember much of it
18:15 janus joined #mojo
18:22 perlpilot joined #mojo
18:25 disputin joined #mojo
18:40 McA joined #mojo
19:01 punter joined #mojo
19:23 neilhwatson joined #mojo
19:43 sugar joined #mojo
19:46 Adurah joined #mojo
19:48 atom123 joined #mojo
20:04 mikegrb joined #mojo
20:04 cosimo joined #mojo
20:05 crux joined #mojo
20:08 upasana joined #mojo
20:08 PanzerBjorn joined #mojo
20:09 PanzerBjorn Is there any reason that the route $b->any('/dash/:action' => [action => qw(one two three)])->to( controller => 'dashboard' )->name('dashaction') should not work?
20:10 upasana_ joined #mojo
20:10 pink_mist you're using $b as a variable name
20:10 pink_mist that's an error
20:10 disputin joined #mojo
20:10 PanzerBjorn Um... Other routes using $b are working fine.
20:10 pink_mist so it could cause many weird and random issues
20:10 pink_mist maybe you were just lucky
20:10 pink_mist $a and $b are special
20:11 pink_mist don't use them as variable names except in sort and List::Util code blocks
20:11 PanzerBjorn I'm pretty sure they're only special within specific contexts or scopes.
20:11 Grinnz_ they're always special, because they're global
20:12 CHYC PanzerBjorn: According to the docs, you probably want [action => [ qw(one two three)]]
20:12 pink_mist good point
20:12 PanzerBjorn Yeah, I tried wrapping the qw() in [] before, that wasn't working either.
20:13 PanzerBjorn I've renamed $b to $bridge just to spite the new way Mojo does bridges.
20:15 PanzerBjorn Nope, that wasn't it.
20:15 iamb it has to be a ref with [], or else you just have a list; action, one, two, three
20:16 PanzerBjorn The current line is this now: $bridge->any('/dash/:action' => [action => [qw(one two three)]])->to( controller => 'dashboard' )->name('dashaction')01
20:17 PanzerBjorn And still results in a 404
20:17 pink_mist weird, for some reason your code got coloured black 0_o
20:17 dustinm joined #mojo
20:17 pink_mist (a bit hard to make out on my black background)
20:17 iamb for me too, no can see
20:18 PanzerBjorn Must be from copy-pasta.
20:18 pink_mist had to go to the irclog to see it
20:18 esh joined #mojo
20:20 pink_mist I'm maybe [action => qr/one|two|three/] ?
20:20 CHYC joined #mojo
20:20 pink_mist -I'm
20:20 PanzerBjorn Worth a try.
20:20 pink_mist no idea if you'd need to anchor it
20:21 PanzerBjorn Nope, don't need anchors for restrictive placeholders.
20:22 PanzerBjorn They auto-match the full strnig
20:22 iamb from what you have it looks right to me, i am using very similar routes with an action placeholder and an array ref of possible values like you have
20:22 PanzerBjorn Damn, still no good.
20:24 Grinnz_ what route are you trying? and what route(s) is this one under?
20:25 jberger I'm guessing you have a route higher up that is consuming your request
20:25 jberger remove the restriction entirely and see if it works
20:26 PanzerBjorn Nevermind, something's wrong woth hypnotoad, it's not relaunching. I don't like that hypnotoad is completely silent about failures to launch. =P Grrr.
20:27 PanzerBjorn I always forget how to check to see what's hanging up hypnotoad.
20:31 Shaeto joined #mojo
20:32 batman PanzerBjorn: it's not silent. you either see it in the log file, STDERR or both
20:33 PanzerBjorn How about neither in my implementation? Maybe I shouldn't be using upstart for my mojo server, who knows.
20:33 pink_mist no I don't! because I start hypnotoad like: hypnotoad foo &>/dev/null
20:33 pink_mist :P
20:33 PanzerBjorn I get neither log lines nor STDERR when launching using upstart.
20:34 batman PanzerBjorn: yeah... upstart is really good at hiding errors :(
20:34 batman maybe it's in syslog?
20:34 PanzerBjorn Well, it's also a really convenient and simple way to get a process to launch on reboot and to shutdown at various service levels.
20:34 * batman never used various service levels
20:35 * pink_mist uses a @reboot line in his crontab for starting a few hypnotoads on reboot
20:35 PanzerBjorn Completely unrelated error was preventing my changes from taking effect on restarts, so my bad. The initial question wasn't even actually an issue - the route worked fine. At least I got away from using $b - thanks guys.
20:36 PanzerBjorn Yeah, there's a syslog line for it, but it's awful vague. "init: mojo-mysite main process (pid#) terminated with status 255"
20:39 Shaeto1 joined #mojo
20:41 punter joined #mojo
20:42 punter Is it possible to construct a URL for my site with url_for, but not from within a route handler, but from a standalone script?
20:43 punter Normally I'd type $c->url_for and that would automatically calculate the hostname, scheme etc
20:43 punter How do I handle it now that it's running from a script?
20:43 punter "You don't"?
20:43 punter is that the answer?
20:44 PanzerBjorn That would be my guess.
20:44 PanzerBjorn How would your script know about the routes in your mojo setup?
20:44 batman punter: are you sure url_for() includes hostname and scheme..?
20:44 good_news_everyon joined #mojo
20:44 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vV3C9
20:44 good_news_everyon mojo/master cc2c45a Sebastian Riedel: explain how $a and $b are used
20:44 good_news_everyon left #mojo
20:44 sri you know, ->reduce is really hard to explain :) http://mojolicious.org/perldoc/Mojo/Collection#reduce
20:45 punter batman: I normally do $c->url_for('page_name') and the full URL gets constructed
20:45 batman punter: which version of mojo is this?
20:45 PanzerBjorn That wouldn't even work for me considering my mojo instance serves multiple domains.
20:46 batman punter: url_for("foo") generates "/some-foo-route" for me
20:47 punter batman: 6.10 - I also have to add to_abs and to_string
20:47 batman punter: right... that's pretty important.
20:47 batman ...to mention
20:47 sri you can do app->build_controller->url_for('some_route_name') to get the relative version, but it can't know the host or scheme
20:47 punter url_for('name')->to_abs->to_string
20:47 punter ok
20:47 punter I'll hard-code it then. thanks
20:48 batman punter: that's probably a very bad idea.
20:48 punter yes
20:48 PanzerBjorn I agree. You shouldn't have to hard-code URIs.
20:48 batman i would use another hack... give me a sec
20:48 PanzerBjorn Unless you're explicitly doing a domain xfer.
20:50 batman punter: this is also probably a bad idea, but i think it's better than hard coding :/ https://ssl.thorsen.pm/paste/ffce65459677
20:50 punter thanks, i'm checking it
20:51 batman so... url_for() uses $c->req->url->base() to construct the full url
20:51 batman sine the routes only have relative url information
20:51 batman *since
20:52 sri umm, what?
20:52 sri batman: that's just wrong
20:53 sri before_routes is executed while dispatching
20:53 sri at that point you always have a request
20:54 batman maybe i misunderstood the question :/
20:54 batman if so... ignore me punter
20:54 punter oh ok
20:55 punter I'll place the base URL in an environment variable, and hard-code the path. That's sufficiently good (even though not perfect_)
20:55 sri batman: what you're thinking of is rewriting http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Rewriting
20:55 batman yes. i thought punter wanted something else than "localhost" when calling the script from command line
20:55 punter (the idea is to have a cron script send out emails containing links to the site)
20:56 Shaeto1 left #mojo
20:58 sri soooo, this is also not correct english? https://github.com/kraih/mojo/pull/943/files#diff-5673597847bee81d4615bbe62681edffR237
20:59 tchaves joined #mojo
20:59 sri from what i understand, a colon may only be used after a complete sentence, but not a sentence fragment
21:01 sri bet 90% of people who have english as their first language can't answer that ;p
21:06 lluad Looks perfectly reasonable to me.
21:06 lluad And I learned native English, in England, from English people.
21:07 punter how can i HTML-escape a string with the Mojo:: modules?
21:08 punter can't find it in Mojo::DOM or Mojo::DOM::HTML
21:08 Grinnz_ sri: that is a complete sentence
21:08 lluad punter: Is there something in Mojo::Util?
21:09 punter yes
21:09 punter xml_escape :-)
21:21 bpmedley sri , jberger : May I ask what you think of this code?  https://github.com/kraih/mojo/compare/master...brianmed:master
21:22 sri bpmedley: horrifying
21:22 bpmedley Why?
21:23 sri you hacked minion stuff into a mojo module
21:23 sri my first instinct is to run away screaming
21:23 bpmedley So, you don't think minion should ever autostart?
21:23 sri you asked for my thoughts on the code
21:24 jberger bpmedley: yeah, that can't be done
21:24 sri not sure what you were expecting, maybe you should ask more specific questions?
21:24 jberger putting minion directly into the app server is ... not possible
21:24 bpmedley From a workflow standpoint, do you think that minion should autostart?
21:24 jberger it has to be part of the app if anything (and in that case a plugin)
21:25 bpmedley jberger : Logically or technically?
21:25 jberger only if it can be done as a plugin
21:25 jberger logically
21:25 jberger technically you can do anything turing lets you do
21:26 jberger but you can't inject a job queue into the app server from a practicality standpoint
21:27 bpmedley Since you disagree from a logical standpoint, I won't waste any more time..
21:27 sri i would have been less horrified if it didn't fork off the minion manager
21:28 jberger bpmedley: can it be done as a plugin (ie with next_tick) somehow?
21:28 bpmedley jberger : I'll have to ponder that.
21:28 bpmedley sri : Perhaps a hint for an alternate approach?
21:28 sri from what i can see you have once again the problem that the parent might just go away without the minion worker noticing
21:30 sri bpmedley: are you just testing random ideas, or is this inspired by something existing?
21:30 bpmedley sri : Sure, that's an issue and a very prevalent one for this scenario.
21:30 bpmedley I think it would be beneficial for an app to start with the web server and job server in one command.  This way a user wouldn't have to do anything for certain situations.
21:31 bpmedley For example, a video encoding web app that used ffmepg and minion.
21:31 sri you're ignoring the hard problems
21:31 sri like parent going away, that's really what makes it hard, just forking off some process is easy
21:32 sri you have to make it reliable
21:32 sri stuff dies, signals get lost
21:33 bpmedley Sure, and I wasn't saying that this code is bullet proof; just wondering about implementation and the logical aspect from a workflow perspective for auto launching minion.
21:33 sri honestly, ignore minion completely, start by finding a way to safely fork off a "while (1) { sleep 1 }"
21:33 sri just a random companion daemon process plugin or so
21:34 sri minion is irrelevant to the problem
21:35 bpmedley Hrmm.  I see your point technically, I'm curious if something like Minion auto-starting would ever be an accepted feature.
21:36 sri it doesn't have to be
21:37 sri fwiw. i'm in favor of having the ability to run random companion daemons with the mojolicious web servers, so if they need additional core hooks, we should be able to do that
21:37 sri but i don't think they do actually, it should all be possible with a plugin already
21:38 bpmedley Awesome, that's exactly what I was hoping to hear.
21:38 sri maybe a way to react to the CHLD signal to restart the companion daemon
21:39 sri but it has to be well explained with technical reasons
21:41 jberger sri: now that's a reasonable idea (companion daemons with hooks)
21:41 bpmedley Sure, so there would have to be several things.  The first is that the child must be cleaned up programmatically at server exit; second, there must be a way for the child and parent to detect if either go away (and either restart or exit as appropriate); and, missed signals should be minimized.
21:43 bpmedley Also, an appropriate mechanism for inclusion should be used - most likely a plugin.
21:43 sri exactly, isolate those problems, find solutions, make a prototype
21:43 bpmedley Did I miss anything?
21:43 bpmedley Also, I hadn't considered launching arbitrary daemons.. that's pretty cool.
21:44 jberger oh yummy, postgres' UPSERT can take a where condition to only update if the condition is true
21:44 jberger <3
21:46 s1037989 bpmedley: Good luck!  Your success on this will be extremely valuable and appreciated!!  I'm looking forward to what this could do for Mojolicious!
21:46 bpmedley s1037989 : Spanx.. :)
21:47 s1037989 sri pushes hard, but he's a good leader...  :D  Lots to learn!
21:48 jberger I mean, you need a strong lea... ALL GLORY TO THE HYPNOTOAD!!!
21:48 sri interesting thing, Mojo::Server::Prefork does already have a hook for CHLD
21:48 sri the reap event
21:49 sri that may be all you need there
21:49 bpmedley sri : Yeah, almost all the code for this is nicely tucked away in the Server packages.. :)
21:49 sri we even use it for a similar purpose
21:49 sri hypnotoad subscribes to it to notice if a newly forked hypnotoad manager died during hot deployment
21:50 bpmedley I was thinking of using the heartbeat code over a pipe for detecting if either child or parent go away.
21:50 sri now, you don't have that event in Mojo::Server::Daemon, that might be problematic for you
21:50 sri you don't even need heartbeats, just have a pipe and watch if it gets closed
21:51 bpmedley That would be simpler.
21:51 sri so, two problems i see, a) Mojo::Server::Daemon has no reap event, since it has no child processes, and b) apps have no access to the server instance
21:51 human39 joined #mojo
21:52 s1037989 Is b) strictly intentional? That is, you specifically don't want apps to have access to the server instance, correct?
21:52 sri yes
21:53 sri that's a pretty big design decision
22:08 s1037989 jberger: On M::P::SimpleSlides, you don't really care what I do with it do you?  There's no reason for you or anyone else to care if I change the packaging process, right?  I'd like to ship the latest version with support for Mojo 6.0 using App::git::ship.  Sorry for the novice question...  I haven't shipped a whole lot of code.
22:08 jberger s1037989: as far as packaging goes, not at all, go for it
22:09 jberger if you want to materially change the module I'd like you to run that past me
22:09 jberger I might not even care, honestly, but I wouldn't know until I'd see it
22:09 s1037989 Thanks!  Perfect -- also what I wanted to know.  Thanks for specifying that, too!
22:09 jberger remember that I was THIS CLOSE to just nuking it, so you can tell my level of care for it ;-P
22:09 s1037989 :D
22:32 batman s1037989: If jberger was about to nuke it... Have you seen
22:32 batman https://metacpan.org/release/App-remarkpl
22:35 s1037989 batman: No, that's great!  Thanks!  Do you know, can I mount a App::remarkpl presentation in Toadfarm?  I ask because another presentation app App::MojoSlides? didn't seem to be written in a way conducive to mounting.
22:36 batman s1037989: yes you can. It's just a mojo app
22:37 s1037989 Great!  I'll go check this out now.  Thanks for the pointer!
22:39 batman You have to fiddle around with some environment variables though...
22:39 batman Look at the source code. It's not very long
22:41 batman 40 lines I think...
22:41 saki s1037989++ Mojo::Sendgrid
22:42 s1037989 batman: Thanks!
22:42 s1037989 saki: Thanks!
22:47 s1037989 batman: I sent you a PR on git ship.  I didn't merge myself because it's out of sync and I don't know which is correct, altho I guess technically the code is more correct than the doc.  :)
22:49 s1037989 saki: I'm glad you like it.  I'm sick of configuring SMTP on a network anywhere I want to send an email.  I'm done with it.  I think I will forever rely on Sendgrid to handle all of my email-sending needs!  :D  And their free service has insanely high limits.
22:55 saki SendGrid can't seem to get Email::SendGrid on CPAN and it's a horrible rewrite of their Python version
22:57 saki saw Mojo::Sendgrid up a couple of days ago <3 mojo :)
22:57 s1037989 Mojo is the best!!
23:05 punter sri: I'm confused. You said "you can do app->build_controller->url_for('some_route_name') to get the relative version" - but how do I get "app" to point to the right app from a standalone script that just sends emails? Could you please point to me to a module I should read?
23:06 bpmedley punter : May I ask what you're trying to do?
23:07 punter bpmedley: I'm writing a standalone script that sends emails. Emails must contain URL to the website. I want to construct those URLs using the url_for method of controller.
23:07 punter bpmedley: but I have no controller, so sri suggested a trick to create one
23:08 bpmedley my $server = Mojo::Server->new;  my $app = $server->build_app("AppName");    <-- My guess
23:08 punter bpmedley: and then $app->build_controller->url_for ? Thanks
23:09 bpmedley Let me look, one sec.
23:09 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Application-embedding
23:09 punter thanks
23:09 punter !
23:23 s1037989 batman: remark is *perfect*!!  Has all the features I'm looking for and some I didn't think possible: clone view!!
23:29 meshl joined #mojo
23:45 tchaves joined #mojo
23:54 jberger s1037989: try revealjs on for size too
23:55 jberger http://lab.hakim.se/reveal-js/#/
23:56 jberger That's what all my talks use now
23:56 jberger Remark and reveal are probably pretty comparable in features i imagine
23:59 jberger http://jberger.github.io/MojoliciousIntroduction/
23:59 jberger My pluggin is basically a layout and a preprocessor

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