开发者

How to save a Pharo image automatically every hour?

I want to save my Pharo image every hour on the hour automatically.

How would you make this automatic within the image?

I've s开发者_如何学编程een the Pier project do this. But I'm not sure how they do it.

TIA


There is the Scheduler project on SqueakSource that looks like cron for Smalltalk. From the overview:

"Start a new task scheduler and keep it around"
scheduler := TaskScheduler new.
scheduler start.
"Let's save the image every hour"
scheduler
   do: [Smalltalk snapshot: true andQuit: false]
   every: 60 minutes.

You could combine that with the blocking code or OSProcess's saveImageInBackgroundNicely mentioned above and have a nice easy solution.


Result of a discussion on the mailing list, with some icing around to run it only hourly:

[[self blockUI.
  self doUpdate.
  SmalltalkImage current snapshot: true andQuit: false.
  self unblockUI.
  (Delay forDuration: (Duration hours: 1)) wait] repeat] fork


You can do it and it might work just fine.

But I wouldn't do it.

Not fot persistence in production.

Why?

Because images are like your session in your laptop. Saving your image is like putting your laptop to sleep: it persists everything.

And in the long run, some state will have some unexplainable shit that can complicate something and you will need to do a hard reboot.

It doesn't help to try to be perfectionist about it (or maybe it does but is certainly not economic). It will just happen and rebooting your laptop is the cheap solution to have fresh state. But that for your smalltalk app may not be that cheap.

A hard reboot in smalltalk will mean that you have to take a fresh image and load again all your code (it can be automated but experience tells that could be time consuming).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜