I need to run certain services when Moqui starts up to initialize settings and seed data. I’m looking for the best way to do this and any advice on handling it efficiently.
Specifically, I’d like to know:
What’s the most effective method to run services at startup?
Are there any issues to watch out for, like running services repeatedly?
Any guidance or examples would be greatly appreciated!
To run a service on startup, my favorite way is to manually run a service in the data files. Once you’ve gotten your seed data running on startup, you would add a line into the file that looks like this (link):
The whole idea of data loading is for things to run themselves. If on the other hand you want the output from one service to put it in another service or something then at that point this is complexity that goes beyond what the data loading system is designed for. If you need a more elaborate logic, then one possibility is to create a higher level service that then chains the service calls however you want.
Thank you, @taher, for the quick response
I understand now that the data loading system is designed for automatic, standalone execution without output handling between services. I was considering creating a higher-level service to manage any necessary chaining and output handling, so your advice confirms that this is the right direction.