[Tutor] demon / app I/F better way ?

Alan Gauld alan.gauld at freenet.co.uk
Sun Nov 14 18:54:55 CET 2004


> my main app when it is ready to accept data checks the status of
> /data/data_flag every second, if it changes to a true state reads in
> /data/data_new & sets /data/data_flag to false, performs processing
then
> checks /data/data_flag ...
>
> This will work (I think ;-) ) but seems a bit clunky, anyone got a
more
> elegant solution?

There are several other solutions including launching the second app
from the first but your way will work for most cases. Be careful about
the effect of the second app locking the files for the first app
- either have a fallback strategy to write to a second file or just
dump the data in dev/null.

Another option you might consider is to use different files for each
data dump, timestamped perhaps then your processing app simply deletes
the files as it processes them. This also covers the locking problem
and allows you to process multiple files at once if updates are
frequent... Finally it makes manual recovery of errors much easier.

And of course you should se an environment variable or config file
to set the data path to get round potential system file structure
changes between machines/operating systems etc.

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list