There are times when you need to load Tcl packages @ startup. There
are also times when you might want to have a one-time
"initialization" of those packages before the server starts accepting
connections. For example, you might have a package that registers a
filter or a proc.
The current implementation "ns_ictl package require" will re-require
packages and re-eval namespaces on every interp clone. This is good
for some reasons and should not be changed, but it does not give us a
"one-time" initialization.
I have added a tcl file to my AOLserver installation called
"packages.tcl" that does the following:
1) Reads the nsd config to set library paths and load needed packages.
2) Looks for and executes the special command ::$
{packageName}::nsInit after ALL packages have been loaded.
3) Looks for and executes the special command ::$
{packageName}::nsPostInit after ALL nsInit procs have been executed.
The config look like this:
ns_section "ns/server/server1/packages"
ns_param librarylist [list /Users/Michael/builds/aolserver/
packages]
ns_param packagelist [list rpc TclCurl foo bar]
This has really helped me pre-load packages for a core distribution
and allowed me to use package deployments for AOLserver level code
like "ns_register_proc" and "ns_pool set" becase I could start pools
and register them before the server accepted connections.
I want to get a sense of how folks need to load packages using
AOLserver in hopes of adding this functionality to the AOLserver
source. So I have some questions:
1) Is there a need to add package loading (like what I have done) to
the core AOLserver distribution?
2) Is there a need to have a nsInit proc per package and when should
that proc be executed:
a) Right after right the package has been loaded - and before
the other packages are loaded? (basically in line with the load list).
b) After all the packages have been loaded (as I am doing in above)
3) Is there a need for a nsPostInit proc and when should it be executed:
a) After all the nsInit procs have been executed but before the
server accepts connections? (as I am doing above).
b) After all the nsInit procs have been executed but AFTER the
server accepts connections?
4) Should package load order be respected?
5) Are there other ns* procs that would be useful?
6) Other ideas on the config structure?
I personally do not code in a way that needs load order, but others
might, so my own opinion is that: Load order is easy to keep so why
not; nsInit procs should be fired after ALL packages are loaded; and
nsPostInit procs should be fired after ALL nsInits have been
executed. This would give a nice way to initialize packages before
the server accepts connections.
I also think that any triggers that need to happen like
"ns_atshutdown" can be registered in one of the init procs so we do
not need to complicate things by have many "special" commands.
Thoughts?
M
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]>
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject:
field of your email blank.