In the documentation I see that OnServerStart and OnServerInstall both fire before the server has started. I would like to run a cfm file to create my datasources. (I know there are many posts already asking this.)
Can I run run a cfm file during one of these interceptors to add my datasources? What is the best way to share the interceptors so that when a coworker pulls from github and then runs the command box start it will already be registered.
Sorry if these are simple questions that the documentation answers I was just unable to find them.
Thank you in advance
Hi Lonnie, the difference between onServerStart and onServerInstall is that onServerStart runs before EVERY server start and onServerInstall runs every time a new CF engine is installed (initial start, after you “forget” the server, or when a new version of the engine comes out).
The easiest way for you to run a .cfm file is simply to create a package script that uses the exec myFile.cfm
, however package scripts are not run on the actual CF server-- they are run from within the CLI which means they can’t use things like the AdminAPI.
What I would recommend you look into is a new project currently in alpha called CFConfig. It is designed for this sort of thing and can be run from a package script as well to automatically add config to the server.
https://www.ortussolutions.com/blog/introducing-cfconfig-a-new-way-to-manage-your-cf-servers-configuration-from-the-command-line
Thanks!
~Brad
ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp
E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com