Closed LukasRychtecky closed 5 years ago
you can ask this question in https://clojurians.slack.com/messages/C5K1SHR6X
short answer. At current version of duct, it will build the dependency tree for :duct/daemon
if you want duct to initialize your component, derive your key from :duct/daemon
.
(derive :myapp/scheduler :duct/server)
or define it in duct_hierarchy.edn
under your resources root
{:myapp/scheduler [:duct/server]}
Reference
https://github.com/duct-framework/core/blob/3964492d8d4be266ba7614d29263488e03482112/src/duct/core.clj#L162 https://github.com/duct-framework/core/blob/3964492d8d4be266ba7614d29263488e03482112/src/duct/core.clj#L183
@zerg000000 is correct. To be more precise, when running Duct from -main
, only keys that are derived from :duct/daemon
are executed. This is because when running in a production environment, there are keys that you may not wish to run on every server (such as migrators, compilers, etc.).
When starting Duct through the REPL and (go)
, all keys are initiated by default.
This is detailed briefly in the duct/core docs, but it really needs better documentation.
Thanks for answering. I read the duct/docs
, but it wasn't obvious for me (to derive or use duct_hierarchy.edn). @weavejester what do you think about I'd create a PR withing a note about think into duct/core
's README.md?
I wonder if duct/core is the right place for it. Is that where you looked first of all? Or would the Duct wiki on this project be a better place?
First I looked into Duct's Wiki https://github.com/duct-framework/duct/wiki/Configuration and after I went to https://github.com/duct-framework/core README.
@weavejester What do you think? Where to put the notes?
The wiki is probably the best idea - it's easy to edit, and it was the first place you looked.
I've updated the Wiki https://github.com/duct-framework/duct/wiki/Configuration#top-level-components
If it's OK I think the issue can be closed.
Hi,
I've found out that when I define a top component (e.g. a scheduler for a periodic task -
:myapp/scheduler
) and this component is not dependency for any other component, the component is not initialized. When I put it into keys sequence when starting the app, it worked as expected. E.g.:Am I right that all top components have to be explicitly passed into
keys
whenprep
andexec
?