views:

56

answers:

1

I'm running some basic continuous integration scripts in the form of rake tasks, using cron to automate their running.

I'd like to be able to maintain some form of state between tasks however. I've considered just writing information to a file and reading it back in.

Is there a more "ruby" way of doing this?

+3  A: 

That's a pretty standard technique for this kind of situation. The only way to "ruby" it up a bit would be to make use of a Gem that does this sort of thing for you out of the box, though to roll your own for a simple task of state preservation should not be that hard.

Serializing your state to a file is quite straightforward, as is deserializing to get all the state information you need when restarting. You can easily use the YAML module for this.

That being said, it may be more practical to use something like Daemons to manage a background process that goes to sleep now and then than to rely on something like cron to kick off jobs.

There are a number of background job management task delegators, too, such as Starling and Workling, that might be a better approach to doing your integration scripts bit by bit instead of all at once.

tadman