My web application needs updates from time to time.
When this happens I often have to stop the server and
shut down the JVM. Then the old (current) directories can
be replaced by the new ones, and I restart the server.

It's okay when there are several copies of the server
running behind a load balancer. This allows updates while
the service is available.

I would like to ask what other ways there are for updating
services.
One idea could be to reload a namespace?
The application could offer a way for an admin to kick of
a reload of a given namespace.

Two problems I see:
1) On the dev machine I make the changes and (compile ...)
the system. On the live machine there already exist .class
files with the same name, or at least with a very similar name.
I don't know if there could be naming conflicts, and in such a
case the OS might now allow me to overwrite a .class file, as
it is in use currently. Even if compile produces files with new
names (other number suffixes or something like that) this could
end up in a mess.

2) And even if we can manage point 1) there is still the problem
with atomicity. Or not?
I imagine a chain of n functions. Callers or callees may expect
different args. I would like to update the whole namespace as
one unit. Maybe this already works in Clojure?

One more question:
could it make sense to have a reload function which first saves
the whole namespace (by referencing all toplevel vars and
functions in that ns), then atomically reloads the namespace
from a given path on disk (containing all .class files) and finally
returns the old instances of the ns?

My idea behind this was:
when a web server starts a request then some threads could still
want to continue to execute functions of the old ns because they
did not finish their request.
Or there could be still an open session for some users which
requirs that as long this session exists these specific users are
served with the previous functions, from before the update.
This sounds a bit like making snapshots and transactions over a
namespace.

Please let me know what you think about it, if this makes sense
or would only cause too many problems, or if it won't work, etc.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to