Re: [AOLSERVER] all interps reload?

2007-11-05 Thread Rusty Brooks
I imagine ns_eval "package forget whatever" would probably work, but I 
don't really use package, so you'd have to try it.


Rusty

Dave Bauer wrote:



On 11/2/07, *John Buckman* <[EMAIL PROTECTED] 
> wrote:


What do the other aolserver programmers do to ask all the tcl interps
to reload, so that new code can be brought in without restarting the
server?

I have a technique (described below) but it's not bug-free, so I was
wondering what people recommended?

One possibility, would be to ask all the tcl interpreters to exit on
the next page request, so that a new thread and thus new tcl
interpreter is created, loading up the new libraries.  I don't know
how to do that, though.

Currently, I have a namespaced global variable $reload::time that is
set to the time when the last "package forget/package require". was
run  When I want to reload all interpreters, I set a nsv variable to
the current time, and a function registered as

 ns_register_filter postauth GET /* mooch_reload_check

runs for every page, so that if the nsv's reload time is not the same
as the local interp's reload time, then I run:

foreach p [package names] {
 package forget $p
}

This seems to mostly work, but some interpreters don't play nice.

Other suggestions ?

-john


I use ns_eval {source the_tcl_file} which only works for one file at a 
time, but seems to make sure the files are reloaded in every 
interpreter including scheduled procedure threads. Reloading in a 
filter does not work for scheduled proc threads. OpenACS has this 
technique that reloads changed files in a registered filter, but it 
suffers from the same problem that occaisionally the files are not 
reloaded into the interpreter.


Dave

-- 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.





--
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.


Re: [AOLSERVER] all interps reload?

2007-11-05 Thread Tom Jackson
The new command is ns_ictl (interp control)

Each interp has an epoch and when you grab an interp, this is supposed to be 
checked, ns_ictl can be used to make sure that things are cleaned up or 
initialized. 

I don't have any examples however, but you can see some of it at work in the 
use bin/init.tcl script. For instance, this script closes files when a 
connection closes. Also look at nsd/tclinit.c to see how connection interps 
are managed. Maybe this is the key issue: not all interps are managed the 
same way.

Can you describe what you are trying to achieve and how you test to see that 
it isn't working? It would be nice to see some working code/configuration to 
supplement the documentation.

tom jackson

On Friday 02 November 2007 08:42, John Buckman wrote:
> What do the other aolserver programmers do to ask all the tcl interps
> to reload, so that new code can be brought in without restarting the
> server?
>
> I have a technique (described below) but it's not bug-free, so I was
> wondering what people recommended?
>
> One possibility, would be to ask all the tcl interpreters to exit on
> the next page request, so that a new thread and thus new tcl
> interpreter is created, loading up the new libraries.  I don't know
> how to do that, though.
>
> Currently, I have a namespaced global variable $reload::time that is
> set to the time when the last "package forget/package require". was
> run  When I want to reload all interpreters, I set a nsv variable to
> the current time, and a function registered as
>
>  ns_register_filter postauth GET /* mooch_reload_check
>
> runs for every page, so that if the nsv's reload time is not the same
> as the local interp's reload time, then I run:
>
>   foreach p [package names] {
>  package forget $p
>   }
>
> This seems to mostly work, but some interpreters don't play nice.
>
> Other suggestions ?
>
> -john
>
>
> --
> 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.


--
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.


Re: [AOLSERVER] all interps reload?

2007-11-02 Thread Tom Jackson
On Friday 02 November 2007 11:50, John Buckman wrote:
> > Can you describe what you are trying to achieve and how you test to
> > see that
> > it isn't working? It would be nice to see some working code/
> > configuration to
> > supplement the documentation.
>
> Quite simply, I prefer aolserver interps to load the source once,
> keep it in memory in parsed form.  This makes page load times fast.
> My .adp files tend to be mostly-empty shells that call .tcl procs, so
> that the procs are parsed and in memory already.
>
> On my development machine, I have aolserver set to re-source all my
> code for each page load. That's a lot slower, but it makes
> development easier.
>
> On a production machine, I would like to "push up" a new web site
> software version w/o restarting the web server.
>
> Make sense?

Yes, lots of sense. 

The development point is interesting. I have been restarting AOLserver (run in 
forground mode) during development, but that would also be slow if I was 
working on a lot of code, like restarting OpenACS. 

But last week I wrote a tcl version of ns_conn and ns_return. This allowed me 
to test library code and tcl page code using nstclsh. At first it was just a 
command line thing, but I just wrote a short script to hook it up to 
tcpserver. Here is the example script (note that ::ns::conn::receive listens 
for a GET/POST on stdin by default):

#!/web/nsd45/bin/nstclsh
# Move into parent of pages directory
set home "/web/nsd45/servers/tutos"
cd $home

# Source tWSDL/TWiST
source "modules/tcl/twsdl/init.tcl"

# Move to pageroot
cd [ns_info pageroot]

# Wait for a request to arrive
::ns::conn::receive

# Assume success 
set status 200

# Convert URL to local file
set targetFile [ns_url2file [ns_conn url]]

# Either file exists or is directory with index.tcl
# If not, return file not found.
if {![file exists $targetFile]} {
set status 404
} elseif {[file isdirectory $targetFile]} {

set targetFile [file join $targetFile index.tcl]

if {![file exists $targetFile]} {
set status 404
}
}
if {"$status" ne "200"} {
ns_return $status text/plain "Issues $status"
return
}
# File exists
source $targetFile

##

Suddenly it became a lot faster to develop. Of course this only applies to tcl 
pages, and can't test things like database access. But it is very good for 
testing the actual request/response process.

tom jackson


--
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.


Re: [AOLSERVER] all interps reload?

2007-11-02 Thread Dossy Shiobara
On 2007.11.02, Dave Bauer <[EMAIL PROTECTED]> wrote:
> I use ns_eval {source the_tcl_file} which only works for one file at a time,
> but seems to make sure the files are reloaded in every interpreter including
> scheduled procedure threads. Reloading in a filter does not work for
> scheduled proc threads. OpenACS has this technique that reloads changed
> files in a registered filter, but it suffers from the same problem that
> occaisionally the files are not reloaded into the interpreter.

One thing to note is that by default, ns_eval is asynchronous--it
actually executes the passed script in a ns_job thread, IIRC.

If you have multiple scripts to ns_eval and they are order-sensitive
(i.e., one file must be sourced before another), then do them all from
the same single ns_eval script:

ns_eval {
source fileA.tcl
source fileB.tcl
}

Forgetting that ns_eval is async. and making multiple ns_eval calls can
be problematic if there's dependencies.

-- Dossy

-- 
Dossy Shiobara  | [EMAIL PROTECTED] | http://dossy.org/
Panoptic Computer Network   | http://panoptic.com/
  "He realized the fastest way to change is to laugh at your own
folly -- then you can let go and quickly move on." (p. 70)


--
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.


Re: [AOLSERVER] all interps reload?

2007-11-02 Thread John Buckman
Can you describe what you are trying to achieve and how you test to  
see that
it isn't working? It would be nice to see some working code/ 
configuration to

supplement the documentation.


Quite simply, I prefer aolserver interps to load the source once,  
keep it in memory in parsed form.  This makes page load times fast.   
My .adp files tend to be mostly-empty shells that call .tcl procs, so  
that the procs are parsed and in memory already.


On my development machine, I have aolserver set to re-source all my  
code for each page load. That's a lot slower, but it makes  
development easier.


On a production machine, I would like to "push up" a new web site  
software version w/o restarting the web server.


Make sense?

-john


--
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.


Re: [AOLSERVER] all interps reload?

2007-11-02 Thread Rusty Brooks

Right, I actually do ns_eval $script where script is a series of loads.

Rusty

Dossy Shiobara wrote:

On 2007.11.02, Dave Bauer <[EMAIL PROTECTED]> wrote:
  

I use ns_eval {source the_tcl_file} which only works for one file at a time,
but seems to make sure the files are reloaded in every interpreter including
scheduled procedure threads. Reloading in a filter does not work for
scheduled proc threads. OpenACS has this technique that reloads changed
files in a registered filter, but it suffers from the same problem that
occaisionally the files are not reloaded into the interpreter.



One thing to note is that by default, ns_eval is asynchronous--it
actually executes the passed script in a ns_job thread, IIRC.

If you have multiple scripts to ns_eval and they are order-sensitive
(i.e., one file must be sourced before another), then do them all from
the same single ns_eval script:

ns_eval {
source fileA.tcl
source fileB.tcl
}

Forgetting that ns_eval is async. and making multiple ns_eval calls can
be problematic if there's dependencies.

-- Dossy

  



--
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.


Re: [AOLSERVER] all interps reload?

2007-11-02 Thread John Buckman

On Nov 2, 2007, at 3:56 PM, Rusty Brooks wrote:

I use ns_eval, which can be used to run a command in all  
interpreters.  Honestly, though, I don't fool around with packages  
much with aolserver...  I mostly have directories, and a proc that  
will recursively go through them, starting at a given root.  So if  
I have


Thanks Rusty, that worked well for me.

This works:
ns_eval -sync lib_reload_all

where "lib_reload_all" is a custom proc to resource everything.

Though I would have thought this would work, it didn't work for me:
ns_eval ns_markfordelete

-john


--
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.


Re: [AOLSERVER] all interps reload?

2007-11-02 Thread Dave Bauer
On 11/2/07, John Buckman <[EMAIL PROTECTED]> wrote:
>
> What do the other aolserver programmers do to ask all the tcl interps
> to reload, so that new code can be brought in without restarting the
> server?
>
> I have a technique (described below) but it's not bug-free, so I was
> wondering what people recommended?
>
> One possibility, would be to ask all the tcl interpreters to exit on
> the next page request, so that a new thread and thus new tcl
> interpreter is created, loading up the new libraries.  I don't know
> how to do that, though.
>
> Currently, I have a namespaced global variable $reload::time that is
> set to the time when the last "package forget/package require". was
> run  When I want to reload all interpreters, I set a nsv variable to
> the current time, and a function registered as
>
>  ns_register_filter postauth GET /* mooch_reload_check
>
> runs for every page, so that if the nsv's reload time is not the same
> as the local interp's reload time, then I run:
>
> foreach p [package names] {
>  package forget $p
> }
>
> This seems to mostly work, but some interpreters don't play nice.
>
> Other suggestions ?
>
> -john


I use ns_eval {source the_tcl_file} which only works for one file at a time,
but seems to make sure the files are reloaded in every interpreter including
scheduled procedure threads. Reloading in a filter does not work for
scheduled proc threads. OpenACS has this technique that reloads changed
files in a registered filter, but it suffers from the same problem that
occaisionally the files are not reloaded into the interpreter.

Dave


--
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.


Re: [AOLSERVER] all interps reload?

2007-11-02 Thread Rusty Brooks
I use ns_eval, which can be used to run a command in all interpreters.  
Honestly, though, I don't fool around with packages much with 
aolserver...  I mostly have directories, and a proc that will 
recursively go through them, starting at a given root.  So if I have


modules/a
modules/b
modules/c/d

I can say
myloadproc modules
to reload them all or
myloadproc modules/b
to just reload module b, and so forth.

myloadproc gets the list of files and then does
ns_eval [list source $file]
on each.



John Buckman wrote:
What do the other aolserver programmers do to ask all the tcl interps 
to reload, so that new code can be brought in without restarting the 
server?


I have a technique (described below) but it's not bug-free, so I was 
wondering what people recommended?


One possibility, would be to ask all the tcl interpreters to exit on 
the next page request, so that a new thread and thus new tcl 
interpreter is created, loading up the new libraries.  I don't know 
how to do that, though.


Currently, I have a namespaced global variable $reload::time that is 
set to the time when the last "package forget/package require". was 
run  When I want to reload all interpreters, I set a nsv variable to 
the current time, and a function registered as


ns_register_filter postauth GET /* mooch_reload_check

runs for every page, so that if the nsv's reload time is not the same 
as the local interp's reload time, then I run:


foreach p [package names] {
package forget $p
}

This seems to mostly work, but some interpreters don't play nice.


Other suggestions ?

-john


--
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.



--
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.