[Seaside] Content-Type
C. David Shaffer
cdshaffer at acm.org
Tue Mar 8 21:33:42 CET 2005
Daniel Salama wrote:
> Hello again,
> [snip]
>
> Also, on another note, more Squeak rather than Seaside related, since
> Squeak is its own VM in its own world, can I execute cron-like scripts
> within Squeak? What I'm trying to do is build some sort of a business
> application dashboard and I'd like for the system to re-compute the
> statistics every, say, 5 minutes. Sorry for posting this question here.
Others answered your first question so here's my attempt at the second:
[
[(Delay forSeconds: 300) wait.
StatisticsEngine recomputeStatistics] repeat
] forkAt: Processor userBackgroundPriority
Sorry for the C-like formatting :-) This is often The Simplest Thing
That Could Possibly Work. You can also name the process by sending it
#name: if you have the NamedProcess package loaded. That will make it
easier to see in the process browser in case you need to kill it. If
you want something more like cron (runs at a particular time) it takes
more work but not a lot more depending on how accurate you need things
to be.
In practice I find that I generally want the ability to start and stop
these processes, to have them startup automatically when the image loads
and run some shutdown code before the image exits etc. If you're using
Seaside then you are probably using Comanche/Kom in which case you're
probably using KomServices. If so, then look at the Service class. It
provides an excellent framework for timed services. Attached is an
example that runs like the one above. Start/stop it with:
serv := StaticsEngineService newNamed: 'stats'.
serv start.
serv stop.
If you want to get a list of registered services (like the Kom service)
just explore/inspect "Service services". I use the explorer to manage
my services. There is also a nice way to manage services with
StarBrowser but I don't use SB anymore.
David
--
C. David Shaffer
http://www.cs.westminster.edu/~shaffer
http://www.shaffer-consulting.com
-------------- next part --------------
'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 8 March 2005 at 3:29:48 pm'!
Service subclass: #StatisticsEngineService
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'StatsService'!
!StatisticsEngineService methodsFor: 'running' stamp: 'cds 3/8/2005 15:27'!
computeStatistics
Transcript show: 'Computing statistics'; cr.! !
!StatisticsEngineService methodsFor: 'running' stamp: 'cds 3/8/2005 15:29'!
runWhile: aBlock
[aBlock value]
whileTrue: [self sleepFor: 30000.
self computeStatistics]
! !
More information about the Seaside
mailing list