in reply to Is "die" the best way to be atomic?
I'm not sure quite what those commands are doing, but what happens if you update the hostgroup, but fail to update the host, do you have an inconsistent system then? In which case you need to code some sort of 'undo' sub, which you can pass a value which indicates how far the script got before it encountered an error, and proceeds to undo the previous steps to return to the state the system was in before you started. And *then* it can die, or exit, or whatever..
Eg:
.. or something.. but maybe I misunderstood what you wanted. C.chdir("$staging_directory") or undo(1); system("svn", "update", "base") or undo(2); ... sub undo { my $state = shift; if($state >= .. ) # highest one first .. if($state >= 2) { system("svn" .. ) # undo svn/update/base command } if($state >= 1) { chdir("-"); # undo chdir command } die "Got to level X: $!\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Is "die" the best way to be atomic?
by BuddhaNature (Beadle) on Apr 27, 2004 at 16:28 UTC | |
by castaway (Parson) on Apr 27, 2004 at 17:00 UTC |