GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Rex::Transaction(3) User Contributed Perl Documentation Rex::Transaction(3)

Rex::Transaction - Transaction support

With this module you can define transactions and rollback scenarios on failure.

 use Rex::Transaction;
 
 task 'do-something', 'server01', sub {
   transaction {
     on_rollback {
       rmdir '/tmp/mydata';
     };
 
     mkdir '/tmp/mydata';
     upload 'files/myapp.tar.gz', '/tmp/mydata';
     run 'tar xzf myapp.tar.gz -C /tmp/mydata';
     if ( $? != 0 ) { die('Error extracting myapp.tar.gz'); }
   };
 };

Start a transaction for $codeRef. If $codeRef dies, Rex will run the on_rollback <https://metacpan.org/pod/Rex::Transaction#on_rollback> code to roll back the transaction.

 task 'deploy', group => 'frontend', sub {
   on_rollback {
     rmdir '...';
   };

   deploy 'myapp.tar.gz';
 };
 
 task 'restart_server', group => 'frontend', sub {
   service apache2 => 'restart';
 };
 
 task 'all', group => 'frontend', sub {
   transaction {
     do_task [qw/deploy restart_server/];
   };
 };

This will execute $codeRef if a step in the transaction <https://metacpan.org/pod/Rex::Transaction#transaction> fails.
2021-07-05 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.