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

IRC log for #mojo, 2017-08-25

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

All times shown according to UTC.

Time Nick Message
00:00 leffe what holds $logged_in ? Routes? ...
00:00 pink_mist $logged_in is somewhat equivalent to a group {}
00:02 Grinnz https://metacpan.org/pod/Mojolicious::Guides::Routing#Nested-routes
00:02 Grinnz you can nest any routes, the difference is when the parent is an under, there will be an intermediate route, otherwise there won't
00:03 leffe Could I write just $r->under{ return check_user() }; $r->get('/protected_stuff', ...)
00:03 Grinnz no
00:03 Grinnz the sub passed to under() is the action method, that doesn't get run until you actually get a request
00:03 Grinnz these routes are set up in app startup
00:05 leffe sorry I meant $r->under(sub {...} ); $r->get('/protected_stuff'' ..)
00:05 Grinnz theres basically no difference unless the under is applied to a route that isn't '/'
00:05 pink_mist leffe: you can do: $r->under(...)->get('/protected_stuff', ...)
00:06 pink_mist leffe: but $r->under(); without storing the under anywhere or using it directly doesn't do anything
00:06 pink_mist anything useful at least
00:06 Grinnz my $intermediate = $r->under('/foo'); $intermediate->get('/bar'); # this matches the url /foo/bar, and runs the /foo action first
00:06 leffe So the DSL under ... protected routes works only in Lite
00:07 leffe with a 'Grown app' you have to do it as you showed me.
00:07 Grinnz group is a Lite workaround for not having the object-oriented interface in Lite
00:07 leffe Ok. Understood!
00:08 leffe This part is tricky ...
00:08 leffe To finish.
00:08 leffe I think I have read it somewhere. is it possible to have SSL with Mojolicius. Right=
00:08 leffe ?
00:09 pink_mist sure
00:09 Grinnz if you install IO::Socket::SSL, it can listen on https and Mojo::UserAgent  can make https requests
00:09 pink_mist usually you let the frontend webserver deal with that though
00:09 Grinnz you still have to supply the ssl cert
00:09 pink_mist but yes, you can make the mojo app server do it too
00:09 leffe I won't have a front end web server.
00:10 leffe How can I switch from 80 to 8080? do I have to have two servers?
00:10 Grinnz what do you mean "switch"?
00:10 leffe login:80
00:10 leffe logged:8080
00:10 leffe ssl
00:11 pink_mist ssl is 443
00:11 Grinnz you would need an application listening on both of those ports, yes
00:11 leffe ok
00:11 Grinnz it could be the same application, but then you'd have to check what port the request comes from, and mojo isn't very good at that
00:11 pink_mist a single instance of any of the mojo servers can listen on both ports
00:11 Grinnz webservers like apache and nginx are better at that
00:11 pink_mist no need to run multiple copies
00:12 pink_mist though yes, what Grinnz said
00:12 Grinnz also, if you need your mojo server to listen on 80 or 443, you'll need to start it as root, so it's recommended to use https://metacpan.org/pod/Mojolicious::Plugin::SetUserGroup
00:12 leffe I run a very small app, it runs on an embedded device, no room for apache or nginx.
00:13 Grinnz and i dunno if you misspoke, but if you're going to have https, logins should always occur already on https
00:14 leffe First page will be on port 80 ...
00:15 leffe Any way I guess I can have it all on https:// ...
00:15 Grinnz yes sometimes its easier just to make it all https
00:15 Grinnz and make port 80 an unconditional redirect
00:17 leffe A page will be just the status of the device. If it's on, hours working, ... model, software version ... I think this should go on port 80 ... I'll see
00:17 leffe Thank you very much guys. I really appreciate your help.
00:33 tomred joined #mojo
01:25 Lee joined #mojo
01:32 tomred joined #mojo
01:55 tomred joined #mojo
02:34 noganex joined #mojo
02:41 stryx` joined #mojo
03:01 karjala_ joined #mojo
03:25 Lee joined #mojo
04:04 dboehmer_ joined #mojo
04:24 Lee joined #mojo
04:53 zivester joined #mojo
04:57 charsbar joined #mojo
05:56 inokenty-w joined #mojo
06:28 trone joined #mojo
06:52 dod joined #mojo
06:57 dod joined #mojo
07:19 AndrewIsh joined #mojo
07:24 itaipu joined #mojo
07:35 ashimema joined #mojo
07:41 Vandal joined #mojo
07:44 n16gel joined #mojo
08:13 necrophcodr joined #mojo
08:15 necrophcodr I was wondering how to do something like `open(PIPE, "ssh '$server' 'sh task.sh |");` and then read the output and print it, in an IOLoop. Is this doable?
08:20 batman necrophcodr: yes. you can use https://metacpan.org/pod/Mojo::IOLoop::ReadWriteFork or https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Subprocesses
08:20 batman depends if you want to stream the output or just get the whole result in one chunk
08:23 batman here's an example that starts an application and use a websocket to read/write to the application: https://github.com/jhthorsen/app-screenorama/blob/master/script/screenorama
08:26 necrophcodr Quick and useful response, thanks a ton batman, you saved my day!
08:26 batman you're very welcome. hope you figure it out :
08:27 batman :)
08:28 n16gel joined #mojo
08:29 ragnar joined #mojo
08:31 rshadow joined #mojo
08:45 prg joined #mojo
09:48 n16gel joined #mojo
10:58 tchaves joined #mojo
11:07 petru joined #mojo
11:34 Lee joined #mojo
11:40 karjala_ joined #mojo
12:08 marcm joined #mojo
12:48 gizmomathboy joined #mojo
13:38 PopeFelix joined #mojo
14:04 zivester joined #mojo
14:11 bjakubski joined #mojo
14:27 ChmEarl joined #mojo
14:36 eseyman joined #mojo
14:37 stryx` joined #mojo
14:42 mcsnolte joined #mojo
15:42 petru joined #mojo
16:39 * sri yawns
16:41 * jberger throws a marshmallow at sri's open mouth
16:42 sri nom nom
17:10 sh14 joined #mojo
17:20 dod joined #mojo
17:39 eseyman joined #mojo
18:15 sh14 joined #mojo
19:36 maschine joined #mojo
19:36 maschine joined #mojo
20:10 dantti_laptop joined #mojo
20:23 marty joined #mojo
20:37 mtths joined #mojo
21:22 runester joined #mojo
21:26 runester If anyone was available, I had a question about how multiple hypnotoad workers updating a data structure would work. Is there a potential race condition?
21:26 preaction a shared data structure? yes
21:27 runester Like a list used as a queue, with a route for adding or pulling something from the queue. Does each worker get their own copy of that list when they are spun up?
21:27 preaction there are ways around that. i've used lockerd (on cpan) to prevent these problems, and i wrote Mercury to also address some kinds of these problems
21:28 preaction yes, each worker would get its own copy of the list after they're forked
21:28 pink_mist there's no race condition. the workers are in different processes and so the data structure is not shared. unless you specifically use some form of external DB or something to specifically share it. and then it all depends on how that DB does it.
21:29 runester OK; so I would either need to make sure that only a single worker was started or I would need to use some other system (like Redis or a db) was the single source of truth, with each worker reading and writing to that sournce.
21:30 preaction or any of the things i mentioned
21:31 runester I'm reading through mercury, now. I'll take a look at lockerd as well. Thank you!
21:32 preaction mercury would be useful specifically for the queue thing you mentioned
21:32 runester PushPull pattern?
21:32 preaction yes
21:33 preaction also, what's your end goal? is it perhaps Minion?
21:34 runester no, that was just an example. I'm actually working on a key/val service with a web front end. I don't want to re-use redis because I need to make the whole thing encrypted and secure, and it needs a nice web interface and also an API for non-interactive clients. So the data structure would be a hash of lists.
21:35 n16gel joined #mojo
21:37 runester so, if I read the initial struct from disk on start and then each worker wrote back to disk on update (with flock), they could also keep each other informed of any updates with a PubSub pattern, so that the other workers wouldn't need to read from disk every time they served a value.
21:37 preaction then yeah it very much depends on how you want to implement that (encrypted in memory? write-ahead log?) but consistency is going to be difficult
21:38 sri store encrypted values in redis
21:39 sri or postgres or whatever
21:40 runester @sri I may end up doing that, but it would also mean constantly reading from / writing to the single source and not just keeping as much in memory and available. Plus, I was told that redis persistence to disk wasn't great.
21:41 sri around here we favor postgres
21:41 runester :)
21:41 sri *cough* Mojo::Pg *cough*
21:41 runester yeah, I've read that module
21:41 preaction there's also etcd, which might be exactly what you're trying to make
21:42 preaction and there's others in that space like consul apparently, never heard of it before though
21:42 runester I was reading about etcd earlier today. I'm very tempted, because that's like redis but has guaranteed persistence. I guess I was just hoping for as much of a pure-perl option as I could get.
21:43 sri just use a database
21:43 sri not worth the headache
21:44 runester cool; thanks everybody! have a great Friday!
21:44 n16gel joined #mojo
21:44 runester left #mojo
21:58 zen 6/win 1
22:21 Lee joined #mojo
22:27 sri so, the perlironman twitter account is just dead?
22:37 vicash left #mojo
22:38 vicash joined #mojo
22:54 stryx` joined #mojo
22:56 CandyAngel Should I be using the route name to identify the currently selected menu item in the menu bar..? Feels like that's too easy to break to be the right way to do it :P
23:01 iamb joined #mojo
23:02 sri yes http://mojolicious.org/perldoc/Mojolicious/Plugin/DefaultHelpers#current_route
23:04 CandyAngel Ah, good. Thankies. *relief*
23:06 sri same as using names with url_for
23:06 sri i don't consider it particularly easy to break
23:22 Lee joined #mojo

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