Discussion:
Session folders created under /Files not cleaned-up under IIS5
(too old to reply)
Ray Porter
2008-06-20 17:16:41 UTC
Permalink
Hi all,
I've got code to generate PDF files using Rave working just fine, based on
the sample app. When running as a standalone, everything works just fine
and the session folders created under the Files directory are cleaned up as
they should be by code in the OnCloseSession event.

However, when I move to an ISAPI and test under IIS6, those session folders
are never deleted. Is there something else I'm missing that needs to be set
or changed for IIS vs standalone? Is there some permissions setting I'm
missing?

Any suggestions will be greatly appreciated. My test environment is XP Pro
with IIS 5.1, CRS 2007 and IW 9.0.39. Our production server is running
IIS6. I need to get this out to the production server as soon as possible
but these temporary files have to be cleaned up.

Thanks,
=================================
Ray Porter
Information Systems
Applications Development Manager
Division of University Advancement
University of North Carolina at Chapel Hill
Phone: (919) 259-9389
Fax: (919) 843-3314
Pager: (919) 216-4218

***@unc.edu
http://www.unc.edu/~dragon

Meddle not in the affairs of dragons for thou
art crunchy and taste good with ketchup
Jason Southwell
2008-06-20 18:23:08 UTC
Permalink
Post by Ray Porter
the sample app. When running as a standalone, everything works just fine
and the session folders created under the Files directory are cleaned up as
they should be by code in the OnCloseSession event.
Files in the /files subfolder should never get cleaned up... standalone
or otherwise.

The only cleanup done by IW is for files in the usercache folder.

/files is intended for static files to be delivered to the user. usercache
is for temporary files that should be cleaned up when the session termiantes.
Ray Porter
2008-06-20 18:46:06 UTC
Permalink
Jason,
The Rave sample app supplied by Atozed creates temporary folders under
/Files using the session id as the name, then creates the Report.pdf within
that directory. The sample has code in the ServerController OnCloseSession
event to look for those folders and delete them when the session closes.
This is apparently how Atozed recommends handling it since they've
implemented it that way in their own sample application and it works just
fine in standalone. I think I have a permissions issue running under IIS
but I haven't identified what it is yet.

Having said that, you're the second person to recommend the usercache and
that actually sounds cleaner (no special clean-up code in OnCloseSession) so
I'm going to give that a try.

Thanks,
Ray
Post by Jason Southwell
Post by Ray Porter
the sample app. When running as a standalone, everything works just fine
and the session folders created under the Files directory are cleaned up as
they should be by code in the OnCloseSession event.
Files in the /files subfolder should never get cleaned up... standalone
or otherwise.
The only cleanup done by IW is for files in the usercache folder.
/files is intended for static files to be delivered to the user.
usercache is for temporary files that should be cleaned up when the
session termiantes.
Jason Southwell
2008-06-20 20:50:59 UTC
Permalink
Post by Ray Porter
Having said that, you're the second person to recommend the usercache
and that actually sounds cleaner (no special clean-up code in
OnCloseSession) so I'm going to give that a try.
I'm not sure why the example shows the /files directory, but usercache is
the appropriate place for this. And you are right that you wouldn't need
any special cleanup code.
Ray Porter
2008-06-20 23:34:17 UTC
Permalink
Post by Jason Southwell
Post by Ray Porter
Having said that, you're the second person to recommend the usercache
and that actually sounds cleaner (no special clean-up code in
OnCloseSession) so I'm going to give that a try.
I'm not sure why the example shows the /files directory, but usercache is
the appropriate place for this. And you are right that you wouldn't need
any special cleanup code.
Jason,
I've switched my code to use UserCache but I still have a question. Running
under IIS5 on my workstation, the temporary files don't seem to be deleted
when the session timeout has passed. I have my timeout set to the default
10 minutes and the temporary folders and PDF files were still in
\Windows\Temp at 20 minutes. They were deleted when I stopped the web
server and closed everything down. When are these files actually cleaned up
by IntraWeb?

Thanks,
Ray
Jason Southwell
2008-06-24 16:54:59 UTC
Permalink
Post by Ray Porter
10 minutes and the temporary folders and PDF files were still in
\Windows\Temp at 20 minutes. They were deleted when I stopped the web
server and closed everything down. When are these files actually cleaned up
by IntraWeb?
If you are placing them in the root of the user cache, then they would be
deleted when the server is shut down. But if you place them in the user's
individual directory under user cache, then it should get deleted when the
session is destroyed.
Ray Porter
2008-06-24 18:39:04 UTC
Permalink
Post by Jason Southwell
Post by Ray Porter
10 minutes and the temporary folders and PDF files were still in
\Windows\Temp at 20 minutes. They were deleted when I stopped the web
server and closed everything down. When are these files actually cleaned up
by IntraWeb?
If you are placing them in the root of the user cache, then they would be
deleted when the server is shut down. But if you place them in the user's
individual directory under user cache, then it should get deleted when the
session is destroyed.
Thanks, Jason. Here's the code snippet I'm using to create the PDF file. I
can see the folders being created with the session id in the cache folders.
So with this code, should it be cleaned up when the session is destroyed?
Second question, is the session actually destroyed precisely when the
session timeout limit is reached?

Ray

begin
UserSession.RvSystem1.DoNativeOutput := false;
UserSession.RvSystem1.RenderObject := UserSession.RvRenderPDF1;
LFile := 'Report' + FormatDateTime('YYYYMMDDHHMMSS', Now) + '.pdf';
UserSession.RvSystem1.OutputFileName := GServerController.UserCacheDir +
LFile;
ForceDirectories(ExtractFileDir(UserSession.RvSystem1.OutputFileName));
try
UserSession.RvSystem1.Execute;
except
on E: Exception do
begin
AnError := true;
UserSession.AMessage := 'An error occured while generating the
report: ' + E.Message;
ShowErrorPage;
exit;
end;
end;
LURL := WebApplication.UserCacheURL + LFile;
WebApplication.NewWindow(LURL);
end;
Jason Southwell
2008-06-26 14:42:19 UTC
Permalink
session is destroyed? Second question, is the session actually
destroyed precisely when the session timeout limit is reached?
There is a thread that runs periodicly and checks for expired sessions.
If it runs into one, then it frees it.

Not sure how often it is ran, but I wouldn't think a session should be expired
for long before it's gone. Maybe no more than a minute.
UserSession.RvSystem1.OutputFileName :=
GServerController.UserCacheDir +
GServerController.UserCacheDir points to the root of the cache folder. You
should be using the cache dir property from the WebApplication object. Don't
recall the exact property name but you should be able to find it.
Ray Porter
2008-06-27 11:14:53 UTC
Permalink
Thanks, Jason. I'll take a look. The files are being cleaned up. I've had
the administrator for the web server monitoring the box for left over PDF
files with the naming convention I'm using. So far, there've been none on
the box in the mornings and I know some have been created.

I'll take a look at the webapplication property and switch to that just to
be safe.

Thanks again,
Ray Porter
Post by Jason Southwell
session is destroyed? Second question, is the session actually
destroyed precisely when the session timeout limit is reached?
There is a thread that runs periodicly and checks for expired sessions.
If it runs into one, then it frees it.
Not sure how often it is ran, but I wouldn't think a session should be
expired for long before it's gone. Maybe no more than a minute.
UserSession.RvSystem1.OutputFileName :=
GServerController.UserCacheDir +
GServerController.UserCacheDir points to the root of the cache folder.
You should be using the cache dir property from the WebApplication object.
Don't recall the exact property name but you should be able to find it.
Loading...