Fork me on GitHub
#luminus
<
2017-03-16
>
yogthos02:03:55

@lucian303 mount uses namespace hierarchy to infer what states need to be started and the ordfer they're started in

yogthos02:03:12

if you you're not using the db namespace anywhere, then the state defined there will not be started

lucian30302:03:45

@yogthos i'm requiring the db namespace in the namespace that calls one of the functions from it. do i need to do anything more? i also tried adding it to the appname.core namespace in case it needs to be referenced before the actual mount.core/start call, but that doesn't seem to help

yogthos03:03:51

you shouldn't have to

yogthos03:03:55

did you restart the app after

yogthos03:03:12

might also be worth asking in the #mount channel

lucian30303:03:50

yes. the uberjar will also not build, interestingly enough, even w/ that second call. i'll try #mount in the morn. thanks for your help

lucian30320:03:24

@yogthos haven't had much luck in the #mount channel, but if u want to see an example of what's happening, i pushed a test repo to github: https://github.com/lucian303/luminus-test ... it's pretty simple. as soon as i write code to access a db function from any other namespace, i can no longer run the repl, server with lein run, or uberjar. i can't even fix the uberjar by manually calling mount.core/start and i can't even start the repl to load the app

yogthos21:03:14

how are you supplying the db url to your *db* state?

lucian30321:03:07

in profiles.clj. i'm 100% certain the db connection works cause i'm able to get data out

yogthos21:03:37

let me try it locally see what happens

lucian30321:03:41

right now, i call mount.core/start in the namespace that uses the db functions then run the repl then i can call user/start and stop. probably the uberjar is not configured for production right now, but i'm not worried about the uberjar. i'm just trying to see if this works

yogthos21:03:08

ah I think I know what the problem might be

yogthos21:03:17

normal workflow is to start the app using lein run

yogthos21:03:51

this will go through -main and run start-app function that loads mount components in the core namespace

lucian30321:03:23

right. but the exception happens when i run lein run

yogthos21:03:26

if you start the repl yourself, then you have to run (start) in the user namespace

yogthos21:03:36

ok let me try running the project

lucian30321:03:34

lein repl also gives me an exception

yogthos21:03:48

you have (testmount) in your testing.routes.services namespace

yogthos21:03:06

this will get called at compile time before the db state is available

yogthos21:03:36

I was able to run the app without problems once I removed that code

lucian30321:03:39

ok, i finally understand what's wrong and more importantly how to fix it. u're right the call was global and the fix is to create a defstate around that call. seems really simple in retrospect 🙂 thank you for the help!

yogthos21:03:19

no prob, glad to hear it all makes sense 🙂