When we changed the APM to not have to restart the server after installation of a package we marked -init.tcl files for reload so that they would be loaded into every Tcl interpreter.
The problem with this setup is that most of the -init.tcl files do setup that should only be executed once such as shared memory initialization with nsv and scheduling of procs with ad_schedule_proc. My first idea for a solution was to provide a proc called apm_source_once so that you could have in your -init.tcl file something like:
apm_source_once {
# Setup shared memory data
nsv_set ...
ad_schedule_proc...
}
# Execute code that is not shared across interpreters here
...
The problem with this setup is that I have to add the apm_source_once to just about all contents of all current -init.tcl files and it is error prone as programmers may forget to use it.
I therefore suggest that -init.tcl files are only sourced once upon installation. The worst thing that can happen with this approach is that a package that keeps something in its init file that needs to be sourced in all interpreters cannot be used until the server is restarted.
I have noticed a couple of ad_proc definitions in -init.tcl files but these could easily be moved to -procs.tcl files.
If anybody knows of code in any -init.tcl file that needs to be sourced in every interpreter - let me know.
Thanks!
Peter