I think duplicating the code will be a better/flexible option.
(You do not need to duplicate the code, just put it in a code module, and call it from both places).
The problem is that at boot, usually the sdcard is not ready, so your app will crash if your try to access the filesystem in process globals.
If you do duplicate the code in both places, make sure you do not re-initialize the variables (if that is relevant) by using IsPaused(Main) or IsPaused(Service).