Forum OpenACS Development: ad_schedule_proc X dynamic values

Collapse
Posted by Iuri Sampaio on

I've written a custom ad_proc and wrapped it with ad_schedule_proc, and I want to have control over its execution (i.e. enable/disable) through an admin interface.

ad_schedule_proc -thread t 3600 ee_event::request_proposal_sched

...

ad_proc -public ee_event::request_proposal_sched {} {
    Sends periodic requests of proposals to partners
} {
  set enable_p [parameter::get_global_value -package_key "evex-event" -parameter "EnableAutoRequestP" -default 0]

    ns_log Notice "ENABLED_P $enable_p"
    if { $enable_p eq 1} {
  
...

I tried to use a global parameter. I've created the package parameter EnableAutoRequestP, which should work as a switch.

But it seems ad_schedule_proc runs on its own cache previously piled in its stack, in the startup process. So, a change in the parameter value does not affect the next executions of ee_event::request_proposal_sched, unless I restart Naviserver after it.

How could ad_proc_sched be aware of such parameter change, without needing to reboot the system ?

Collapse
Posted by Gustaf Neumann on
Iuri,

i do not think that the scheduled procs use locally cached values. I just did the following experiment using the global parameter "CacheSize" of xowiki for testing purposes.

First, in ds/shell, create a repeating scheduled procedure, which runs every 10 seconds:

set id [[ns_schedule_proc 10 { 
   set cache_size [parameter::get_global_value -package_key xowiki -parameter CacheSize -default 0]
   ns_log notice "xowiki CacheSize: $cache_size" 
}]]

Once the scheduled procedure is running, one sees an entry in the error.log every 10 seconds with the actual value of the global parameter.

When we change the parameter, e.g. via another ds/shell command like

parameter::set_global_value -package_key xowiki -parameter CacheSize -value 50000
then the next log entries are changed accordingly.

When i go to /acs-admin/ to change the global parameter, i see there the value of 50000 for "CacheSize", altering this value to e.g. "50001" has as well the expected result.