duct

g7s 2020-06-17T08:58:43.135800Z

In my app I want to execute some code after the system has been initiated successfully. What is the proper way of doing this?

kwrooijen 2020-06-17T09:02:52.136700Z

Generally speaking, after initialization, code will be executed by HTTP requests / cron tasks

kwrooijen 2020-06-17T09:03:18.137100Z

Not sure what you're trying to do?

g7s 2020-06-17T09:08:02.139100Z

I want to run a setup script for my web app (create stuff that have to be there etc). The script will be idempotent so I would not care if it runs after every system initialization

kwrooijen 2020-06-17T09:11:01.139600Z

As in database rows?

g7s 2020-06-17T09:11:29.140Z

Including database rows

kwrooijen 2020-06-17T09:13:24.141400Z

Ok, I don't think there's really a reason everything needs to be started, right? As long as the database connection is established. You could create an init-key that references :duct.database/sql, and does what it needs to do

kwrooijen 2020-06-17T09:14:14.141800Z

Basically just reference whichever keys need to be started before this one

g7s 2020-06-17T09:17:13.144200Z

Ok so this is what my initial thought was, I asked to see if there is something like a callback to a successful initialization or smth

g7s 2020-06-17T09:17:22.144400Z

Thanks a lot @kevin.van.rooijen

kwrooijen 2020-06-17T09:17:30.144600Z

AFAIK, there isn't

g7s 2020-06-17T09:18:22.144800Z

:thumbsup:

kwrooijen 2020-06-17T09:21:07.145800Z

https://github.com/duct-framework/core/blob/master/src/duct/core.clj#L213-L233 looks like exec-config just starts the system and checks of there are any :duct/daemon keys. If there are, it adds a shutdown hook and blocks infinitely

kwrooijen 2020-06-17T09:21:29.146300Z

Doesn't look like there is any extra logic for hooks and stuff

g7s 2020-06-17T09:37:15.146500Z

Yeah looks like it

Asier 2020-06-17T10:26:27.147200Z

Added here: https://github.com/duct-framework/duct/wiki/Modules