質問

The Seaside book says: "saving [an image] while processing http requests is a risk you want to avoid“.

Why is this? Does it just temporarily slow down serving http requests or will requests get lost or will errors occur?

役に立ちましたか?

解決

Before an image is saved registered shutdown actions are executed. This means source files are closed and web servers are shut down. After the image is saved it executes the startup actions, which typically bring up the web-server again. Depending on the server implementation open connections might be closed.

This means that you cannot accept new connections while you save an image and open connections might be temporarily suspended or closed. For both issues there are (at least) two easy workarounds:

  1. Fork the image using OSProcess before you save it (DabbleDB, CmsBox).

  2. Use multiple images and a load balancer so that you can remove images one at a time from the active servers before saving them.

他のヒント

It seems that it's just a question of slowing things down. There is this quite thorough thread on the Seaside list, the most relevant post of which is this case study of an eCommerce site:

Consequently, currently this is what happens:

  1. image is saved from time to time (usually daily), and copied to a separate "backup" machine.
  2. if anything bad happens, the last image is grabbed, and the orders and/or gift certificates that were issued since the last image save are simply re-entered.

And, #2 has been very rarely done-- maybe a two or three times a year, and then it turns out it is usually because I did something stupid.

Also, one of the great things about Smalltalk is that it's so easy to run quick experiments. You can download Seaside and put a halt in a callback of one of the examples. For example:

WACounter>>renderContentOn: html
...
    html anchor
        callback: [ 
            self halt.
            self increase ];
        with: '++'.
...
  1. Open a browser on the Seaside server (port 8080 by default)
  2. Click "Counter" to go to the example app
  3. Click the "++" link
  4. Switch back to Seaside. You'll see the pre-debug window for the halt
  5. Save the image
  6. Click "Proceed" You'll see that the counter is correctly incremented, with no apparent ill effect from the save.
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top