Fork me on GitHub
#pedestal
<
2017-04-21
>
skylar10:04:04

Can someone give me an advice how to get the hot-loading feature on the development working in the REPL? A link would be helpful, I just couldn't find any relevant from the Pedestal issue or the Stackoverflow. I am running on Pedelstal version 0.5.2.

martinklepsch13:04:55

I want to see the debug log messages of pedestals interceptor.chain namespace — can anyone point me how to enable debug logging for that namespace with pedestals logging lib?

martinklepsch13:04:12

thus I’m ending up with exceptions that are like “Interceptor Exception: Interceptor Exception: …."

ddeaguiar14:04:37

@martinklepsch update the logback.xml config as such <logger name="io.pedestal.interceptor.chain" level="DEBUG" />

ddeaguiar14:04:07

or use TRACE for more info

ddeaguiar14:04:27

no need to restart the service. The change should hotload

ddeaguiar14:04:22

BTW, I’ve found lnav (http://lnav.org/) to be an excellent tool for viewing logs. Here’s my lnav configuration: https://github.com/ddeaguiar/dotfiles/blob/master/shell/.lnav-formats/pedestal_log.json

martinklepsch14:04:31

@ddeaguiar actually was looking for something similar the other day and settled on some other tool. already forgot the name again lol

martinklepsch14:04:59

@ddeaguiar does it support viewing remote log files, potentially from multiple systems at once?

ddeaguiar14:04:25

I’ve not tried that so can’t comment

ddeaguiar14:04:29

that would be cool though

martinklepsch14:04:14

I’ve set up papertrail recently and while that’s helpful some terminal tool that shows me all logs might also be perfectly fine

martinklepsch14:04:26

that said it doesn’t seem to be within the scope of inav

ddeaguiar14:04:38

I was looking for something that made it a bit easier to explore the data structures in the logs

ddeaguiar14:04:17

The query support is nice but I’ve not used it too much

mtnygard14:04:35

IIRC, lnav can view remote logs as long as they're accessible via url

ddeaguiar14:04:41

From the lnav v0.8.0 release notes

- Integration with "" for querying and tailing server log and syslog messages. See the Papertrail section in the online help for more details.
- Remote files can be opened when lnav is built with libcurl v7.23.0+

ddeaguiar14:04:10

I’ve not tried to do any fancy things with it

ddeaguiar14:04:31

being able to dynamically expand and collapse log lines was a huge plus for me but I suppose my expectations were low 🙂

martinklepsch14:04:41

I mostly look at logs with tail -f so I guess my expectations aren’t high either 😄

ddeaguiar14:04:51

hehe, yeah. I just got tired of trying to eyeball the key/value pairs in logged request and context maps

ddeaguiar14:04:21

In any case, my threshold for pain is pretty high. I’m pretty sure my usage of lnav came out of a pairing session with @christianromney. His threshold for pain is lower 🙂

christianromney16:04:26

spell of summoning...yes my pain threshold is notoriously low 🙂

PB19:04:44

How is everyone here reloading their app? I currently have to kill my repl if I make any changes to my service.clj file

PB19:04:15

Pedestal service that is

ddeaguiar19:04:16

@petr was your app built from the pedestal-service lein template?

PB19:04:27

@ddeaguiar it was indeed

ddeaguiar19:04:53

ok, did you start your service using run-dev?

PB19:04:09

I also have to reload for any namespaces required inside of the service.clj file

PB19:04:19

I’m starting a repl and calling the run-dev fn

PB19:04:33

As I like to connect emacs to a repl

ddeaguiar19:04:30

reloading your routes and the and any interceptors/handlers that changed should do it

ddeaguiar19:04:00

for example, if your service code is in service.clj as in the pedestal-service template, just load that file after making changes

ddeaguiar19:04:39

I presume you are trying to load changes you made to routes/interceptors/handlers

PB19:04:46

I am indeed

skylar19:04:49

@petr I was asking the same question

PB19:04:59

But loading that file into my repl doesn’t change anything

PB19:04:05

I find myself having to restart hte repl

PB19:04:11

Maybe it’s cidr?

ddeaguiar19:04:23

doubtful, I use cider + emacs

PB19:04:40

Do you use C-c C-k?

ddeaguiar19:04:05

I think so, let me test

skylar19:04:11

I am using Intellij Idea with local REPL and it's not working

skylar19:04:33

I get it works with Lighttable

PB19:04:48

I remember when light table first came out

PB19:04:54

I was so excited for Chris

PB19:04:06

Its just so unuseable though

skylar19:04:22

That's why I moved to Idea

skylar19:04:36

but for some reason my run-dev is not working

ddeaguiar19:04:06

yeah so it works when I cider-load-buffer (`C-C C-k`)

ddeaguiar19:04:46

I just created a new pedestal service and I can change the home-page fn, reload and see the change

ddeaguiar19:04:50

This should also work with intellij + cursive

ddeaguiar19:04:19

If you change other properties of the service map, like port, etc, then you need to restart

PB19:04:26

So I’m building atest quick

skylar19:04:18

I @ddeaguiar I have the latest Pedestal template and it's not working for me

PB19:04:40

Hah he is right

PB19:04:42

It is working

ddeaguiar19:04:44

hrm, lemme try in intellij

skylar19:04:53

yes please 🙂

PB19:04:54

It’s probably my code not compiling

skylar19:04:06

@ddeaguiar my intellij config: "Run nREPL with Leiningen" and "Synchronize Leiningen Projects"

ddeaguiar19:04:17

ok, I don’t really use intellij so bare with me

ddeaguiar20:04:07

@skylar it works for me in intellij as well

ddeaguiar20:04:35

here’s how I start my service (def s (run-dev))

ddeaguiar20:04:53

then I make a change to a handler in service.clj

ddeaguiar20:04:18

and Sync files in REPL

souenzzo21:04:44

How do I put a prefix in :io.pedestal.http/resource-path?

souenzzo21:04:58

I want to access "resources" via GET/static, for example...

mtnygard21:04:20

@souenzzo I don't know if there's a way to do that right in the service map, but you can add a route like "/static" :get (io.pedestal.http.ring-middlewares/fast-resource nil)

mtnygard21:04:44

That's the same interceptor that gets created for you when you put :resource-path on the service mpa

ddeaguiar21:04:50

@mtnygard should the path parameter be the path in the resources dir instead of nil?

mtnygard21:04:28

@ddeaguiar Probably. That's what I get for trying to beat you to the answer.

ddeaguiar21:04:15

hehe, I’ve not used fast-resource I was going to suggest io.pedestal.http.ring-middlewares/resource

mtnygard21:04:39

Basically the same thing. Fast resource returns async and streams so time-to-first-byte is a bit better.

ddeaguiar21:04:50

good recommendation

souenzzo21:04:55

fast-resource was always from /resources?

mtnygard21:04:21

It uses http://clojure.java.io/resource, so it looks for anything visible in your classpath

souenzzo21:04:17

hum... I think I should make something manual to restrict to html/js/css files...

ddeaguiar21:04:00

I think you can just put the files you are interested in serving resources/public

ddeaguiar21:04:59

looking at the source for fast-resource now… sec

souenzzo21:04:38

Yep. keep all stuff at resources/public and overwrite path-info/uri on ctx

ddeaguiar21:04:10

I don’t think you need to overwrite anything

ddeaguiar21:04:39

hmm maybe so

souenzzo21:04:08

path-info (str "/public" path-info) or some like...

ddeaguiar21:04:46

no I don’t think you need to overwrite anything

ddeaguiar21:04:12

uri-path is (subs ... 1)

ddeaguiar21:04:28

so your route path /static would be dropped

ddeaguiar21:04:39

I’m guessing anyways

ddeaguiar21:04:07

It makes sense to me. It would be odd to have to start manipulating the path to get it to work

souenzzo21:04:03

Maybe rename /resources/static... And let some big comments arround. So: there isn't standard way. I will dig into..

ddeaguiar21:04:35

so, if you configured the interceptor with the root path of resources/public then requests for /static/css/foo.css would resolve to resources/public/css/foo.css

ddeaguiar21:04:57

alternatively you can stick stuff in resource/static and set ::http/resource-path to /static and call it a day

ddeaguiar21:04:08

it is definitely getting late for me 🙂

souenzzo21:04:29

::bootstrap/resource-path "/public" and resources/public/statc will do. Sure with empty resources/public

ddeaguiar21:04:49

yeah that works