Sorry for not getting back to you sooner.
before_app_launch hook would only run if you are running the
tk-multi-launchapp to launch Maya. If you are launching it with your script with your own bootstrap then the hook won’t be called.
If the hook logic needs to be called in both situations, I would move to logic out into a python module somewhere else which you could import from both the hook and your custom launch code.
I also just tested on my side with duplicating the Maya
Software entity for Maya, and setting it up to use batch:
And when I launched it from Shotgun Desktop , I got the following output to the
2020-04-22 09:17:51,148 [61355 INFO sgtk.ext.no_current_bundle.test] doing some Shotgun stuff
What approach you take is up to you and depends on your set up, but if it was me I would have a custom bootstrap script that gets called when Maya launches, and let the farm software handle the launching of Maya.