Forum OpenACS Development: Another possible bug: watched proc files don't get loaded

So I have some ad_procs in a tcl/pkg-key-procs.tcl which can be watched from the apm, when I ask for it to be watched, it doesn't seem to change the proc (I'm taking out/adding ns_loggers atm, no change until I restart whole server).

I thought they would get loaded when I did anything that called the rp, which means pretty much any request, so I click around to make sure, and also look at the apm, sure enough, "being watched". but still no change.

there's a special wrinkle here btw. The proc involved is scheduled with ad_schedule_proc, and I'm given to understand that's a special case. In any case... Ryan Gallimore let me in on a trick: go to developer support shell, and do:

ns_eval [source "[acs_root_dir]/packages/the-package/tcl/the-file-procs.tcl"]

to reload the relevent proc, then you have to make sure it's scheduled. when openacs starts, it reads all packages/*/tcl/*-procs.tcl first -- among other things, you get the tcl library during this phase -- then it reads all packages/*/tcl/*-init.tcl files (so, the inits have the benefit of having all the procs in the entire system loaded). Find what file the scheduling code is in (ad_schedule_proc secs block) and load that file:

ns_eval [source "[acs_root_dir]/packages/the-package/tcl/maybe-different-named-file-init.tcl"]

and this should save you having to restart.

-Jim

Jim, this isn't a bug, but the way ad_schedule_proc evaluates its proc argument. ns_eval'ing the -init file (the tcl file scheduling the proc) is just a shortcut to avoid restarting the server.
Don't ns_eval an -init file, its just supposed to run once. Just [source the/file] instead.

ns_eval loads the file in every thread including scheduled proc threads.

Dave, your TIP (https://openacs.org/forums/message-view?message_id=923672) says that you can use ns_eval to reload scheduled procs on a running server. If your scheduled procs are included in the -init file, you would need to reload the -init file. I realize this is not the convention. Most -init files schedule a proc included in another -proc file.

To reload most proc files, watch it (this uses [source file]) but to reload a scheduled proc, ns_eval the file which contains it.

As we discussed in IRC the watch mechanism is not very elegant, and it adds overhead. It also does not work when a site is in production mode.