Forum OpenACS Development: Re: Image resizing, exec and server problems

Collapse
Posted by Dave Bauer on
I guess you need a way to determine is the exec proxy is available. That is, we use the image:: procs extensively but don't use AOLserver 4.5. As far as I know its not required yet.

Probably if you have an exec proxy setup you'd just want to rename exec_proxy to exec to use it everywhere.

Collapse
Posted by Malte Sussdorff on
I just committed proxy-procs.tcl to acs-tcl. This is creating a wrapper procedure for exec called proxy::exec. It is only available if ns_proxy is installed and configured.

Now.... I could rename "exec" to "real_exec" using the rename command. Interestingly the proxy still requires the call to go to "exec", so I might not even have to do the rename.

Sadly I have no clue how I can write a procedure which checks if proxy::exec exists and then calls it with all the arguments, as exec allows for an arbitrary number of arguments and I don't know how to model that in ad_proc.

Collapse
Posted by Gustaf Neumann on
Malte wrote:

Sadly I have no clue how I can write a procedure which checks if proxy::exec exists
Use [info exists ::proxy::exec]. If it returns empty, ::proxy::exec does not exist.


... model in ad_proc an arbitrary number of arguments...

Try in ds/shell:

   ad_proc ppp {args} {doc} {return "<< $args >>"}
   ppp these are multiple arguments
Collapse
Posted by Malte Sussdorff on
Thanks. The first one is already in use, I was more concerned about the multiple arguments, for whatever the reason it did not like it the way I used it before. Works and is committed.
Collapse
Posted by Michael Totschnig on
Hello Malte,

I just committed proxy-procs.tcl to acs-tcl. This is creating a wrapper procedure for exec called proxy::exec. It is only available if ns_proxy is installed and configured.

what would be the right way to configure ns_proxy in the config file, so that your wrapper works. somehting like ?

load /usr/lib/aolserver4/lib/libnsproxy.so
ns_proxy config exec_proxy

Regards,

Michael

Collapse
Posted by Stefan Sobernig on
Michael, To get the ns_proxy family of commands registered with the driver and connection interpreters, you have to options:
  1. add the following entry to your etc/config.tcl:
    # ...
    if {[ns_info version] >= 4.5} {
      if {[file exists ${bindir}/nsproxy.so]} {                
        ns_param	nsproxy		${bindir}/nsproxy.so        
      }        
      ns_limits set default \
          -maxupload [ns_config ns/server/${server}/module/nssock maxinput]
    }
    # ...
    
    Note, I added it to the 4.5+ branch as it won't be available below. You also need to check for its very existence, otherwise, the you will experience a crash. that would be the option for using malte's "ns_proxy proxy".
  2. as you outlined above, an on-demand / or lazy initialisation in your code (convenient for testing purposes). in xotcl jargon, as I assume that you stick with it:
    Class X -proc init args {
       if {[info command ns_proxy] eq "" && \
     	    [file exists [ns_info home]/bin/nsproxy.so]} {
           load [ns_info home]/bin/nsproxy.so
           # create a proxy pool 
           ns_proxy config my_pool
         }
         next
    }
    
    Provided that you class object is defined in a *-procs.tcl file, the constructor "init" will only be called once, upon initial sourcing in the driver thread. The "info command" expression takes care for its deployment in www/* scripts.
hope it helps, //stefan
Collapse
Posted by Michael Totschnig on
thank you Stefan for the explanation.
I think, since there is code in acs-tcl that gives acces to ns_proxy when it is loaded, it should be included into the sample config file distribibuted with OpenACS. Ubuntu seems to put the library into the lib directory and it is called libnsproxy though.