AppInit() is the main function that initializes the Bitcoin service. The QT wrapper, and bitcoind wrapper to this function wait on the threadGroup after executing AppInit. So, it seems logical to initialize the following variables outside of AppInit and pass them in:
- g_mempool
- chainActive
- gArgs
- the config
Then as an interim solution, AppInit should set these globals to point to the appropriate objects.